Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging)
Why Stack Overflow recommends it
Stack Overflow users link it when answering beginner VBA questions where the asker needs to learn to step through code, inspect variables and understand error types.
Recommended by 2 people across 6 different months, 2016 to 2024.
What it is
Part 3 of Wise Owl's Excel VBA Introduction series, presented by Andrew Gould. It explains the difference between syntax, compile and runtime errors and demonstrates debugging techniques such as stepping through code and using the Locals and Watch windows.
What people said
Strong rec user6432984 · 2016-09 · Stack Overflow · on “Search Excel Sheets for dates to consolidate data by month using VBA”
You should watch this whole video series Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging) [this video] . I'm happy here that it is working for you. Happy Coding!
Recommends user6432984 · 2016-11 · Stack Overflow · on “increase value of an element in array vba”
Your code works as expected. You should watch: Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging) [this video] [LINK] Here I set up watches to monitor your variables. The watches for myArray(2) and myArray(4) are set to break when there value changes. [LINK]
Recommends user6432984 · 2016-11 · Stack Overflow · on “excel vba counters and their lifetime(ish)”
Your question is a little confusing. shcount = worksheets.count is assigning the value 5 to the variable shcount . shcount will remain at 5 until its value is modified. It has no link to the actual Worksheets collection. You should watch this whole series Excel VBA Introduction [LINK] . This video: Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging) [this video] will teach you how to step through your code and check the values of variables line by line. Here I set up a watch for shcount . In this way the value of shcount will be visible in the watch window. Also notice that the variable is in the Locals window. As I step through the code you can see it's value c
Recommends user6432984 · 2016-12 · Stack Overflow · on “Problems with developing incremental +1 function”
@lyeyannian You should watch this series: Excel VBA Introduction [LINK] . This is pretty relavent: Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging) [this video]
Recommends user6432984 · 2016-12 · Stack Overflow · on “Creating UserForm on VBA”
@RexDarwin you should watch this video series: Excel VBA Introduction [LINK] . This is relevant: Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging) [this video]
Recommends user6432984 · 2017-11 · Stack Overflow · on “What is wrong with my OFFSET formula for data validation?”
@ashleedawg also excellent advice. This may help: Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging) [this video]
Recommends TinMan · 2018-11 · Stack Overflow · on “Excel VBA - Subscript out of range”
Arr3 is never The error is caused because Arr3 was never initialized as an array. Arr1(i) will also throw an error because Arr1 is a 2 dimensional array; use Arr1(i, 1) instead. ReDim Arr3(LBound(Arr1) To UBound(Arr1)) For i = LBound(Arr1) To UBound(Arr1) Arr3(i) = Arr1(i, 1) + Arr2(i, 1) Next Dim W1, W2, R1, R2, R3, R4, R5 As Double In the declaration above R5 's datatype is Double the rest are Variants. [LINK] Here are a few videos that will help: Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging) [this video] , Excel VBA Introduction Part 34 - Type Declarations (User-Defined Types) [LINK] and Excel VBA Introduction Part 25 - Arrays [LINK]
Recommends TinMan · 2024-09 · Stack Overflow · on “If then statement with multiple conditions to place values from one sheet into another sheet”
Well said. I would also recommend separating the lines and that the OP watch Excel VBA Introduction Part 3 - What to do When Things Go Wrong (Errors and Debugging) [this video] .
Cites musialmi · 2020-06 · Stack Overflow · on “Standard function use in VBA - how do you write it? With brackets or with spaces?”
I watch VBA tutorials by WiseOwl - e.g. [this video] - and I noticed that he writes functions, he is inconsistent. When he uses Offset , he always writes it this way: Offset(1, 0) - with brackets. When he writes MsgBox , he writes MsgBox "Message" - with space, without brackets. What is the standard way of using functions in VBA? Using brackets is consistent with other programming languages, but if others will frown upon me because I use them instead of spaces, then I'll adjust. Another thing I'd like to ask about additionally is how do you execute a function which has got many arugments and which you want to write in more than one line, hitting enter. Underscore doesn't work, so there's probably