Master VBA Debugging in 20 Minutes

preview_player
Показать описание
👉 Ready to master VBA?
(Note: If the download page doesn't work then make sure to turn off any popup blockers)

Master VBA Debugging in 20 Minutes

In this video, I'm going to cover everything you need to know about Debugging in VBA.
* What is debugging and why you need it.
* When to use the Locals window and when to use the Watch Window.
* The SandBox Method
* Putting it all together - a real-world example
* Plus loads of cool tips and tricks you didn't know

Useful VBA Shortcut Keys
========================

Debugging:
Compile the code: Alt + D + L OR Alt + D + Enter
Run the code from the current sub: F5
Step into the code line by line: F8
Add a breakpoint to pause the code: F9(or click left margin)

Windows:
View the Immediate Window: Ctrl + G
View the Watch Window: Alt + V + H
View the Properties Window: F4
Switch between Excel and the VBA Editor: Alt + F11
View the Project Explorer Window: Ctrl + R

Writing Code:
Search keyword under cursor: Ctrl + F3
Search the word last searched for: F3
Autocomplete word: Ctrl + Space
Get the definition of the item under the cursor: Shift + F2
Go to the last cursor position: Ctrl + Shift + F2
Get the current region on a worksheet: Ctrl + Shift + 8(or Ctrl + *)
To move lines of code to the right(Indent): Tab
To move lines of code to the left(Outdent): Shift + Tab
Delete a Line: Ctrl + Y(note: this clears the clipboard)

Table of Contents:

00:00 - Introduction
00:40 - What is Debugging?
01:19 - Simple Debug Example
01:50 - The Debug Toolbar
02:25 - The Locals Window
03:58 - The Watch Window
05:03 - Watch Window: Using Functions
06:20 - Tips for Debugging Ranges
07:33 - Watch Window: Divide Conquer
08:45 - Step Into/Over/Out
11:31 - Run to Cursor
11:59 - Set Next Statement
12:48 - The Call Stack
13:45 - Show Next Statement
14:17 - Break in a loop
15:43 - The Sandbox Method
17:27 - Real-World Example
Рекомендации по теме
Комментарии
Автор

Enjoy the video. You can download the workbook I used in the description below. Let me know the most useful thing you learned from this video.

Excelmacromastery
Автор

Wow, Paul! I’ve been debugging the hard way for so long … like using a hand shovel when a bulldozer is right there. Thank you!

jimfitch
Автор

Thank you for this video. I've been missing a lot of things in debugging my vba. This is very helpful. Breaking in a loop is awesome. I have been struggling with that. Now I know how. Thanks again

simplejuan
Автор

So much great information in just 20 minutes. I'll definitely rewatch this a few times, but this will help me save so much time debugging. Thanks Paul!

tristanc
Автор

Great intro. (In decades of using VBA, I'd never pondered what Set next statement even meant. Too soon old, too late smart.) Two comments:

1) the advantage of Run to cursor vs setting a breakpoint is you don't have to clear the breakpoint afterwards if you don't want to keep stopping there during this session.

2) I'm somewhat surprised you never mentioned the Immediate window. Some of the things you showed for watch are occasionally better suited to Immediate (i.e., ? x+7700). Also, Immediate allows you to modify variable values on-the-fly (i.e., loopcount=maxloopcount-1). Not to mention Debug.Print...

outby
Автор

Thank You! Knowing how to debug is just as important as knowing how to code.

KM-comx
Автор

Great VBA knowledge sharing sir Paul. So much thankful. God bless you.

freeliberalminds
Автор

This is great. I've also been exploring the usefulness of debug.assert to stop when a value doesn't match what's expected. Not sure if there's any advantage over a watch.

stevegarwood
Автор

Yet another helpful masterpiece. Sir, Thank you for this wonderful explanation. I am still learning excellent VBA tricks from you. It's Awesome.

rahulrock
Автор

Thanks for sharing these very useful tips!! It will help me a lot

ricardoantunes
Автор

Thank you for the real world example. It helped me to get a better understanding how to apply this.

grandpizzaplus
Автор

Thanks for this video. For me it didn't contain much new stuff, but I recommend this video all the time to VBA beginners: friends, colleagues and on Stack Overflow.

junkertom
Автор

I wish I watched this video couple months ago, but only hours of painful debugging made me look for it :) thanks!

bydlosith
Автор

Thanks Paul. Great, as always! Thumbs up!!

wayneedmondson
Автор

The "Break When Value Is True" Watch option is especially valuable. Thank you!

WordBaron
Автор

And once again I left with more knowledge of vba. Thanks Paul.

joaocustodio
Автор

wow, I've been debugging for years and still learned a lot from your video, ty

rafaelsilvareghin
Автор

Wonderful lesson of debugging code.

I am very grateful for the video.
Thanks u

munshirasimraja
Автор

Unbelievably informative video! Thank you for making it!

renyongsun
Автор

Great and knowledgeable video. Thanks for making it and sharing it with us.

kentokawaguchi