Unfortunately, not everything goes right the first time. Excel VBA will sometimes give you a macro error saying that something isn't programmed correctly. There are too many Excel Visual Basic errors to explain them all at this stage. However, here is a good tip to deal with errors.
First, we want to create a macro error.
1. Place a command button on your worksheet and add the following incorrect code line:
MgBox "This is fun"
(instead of the correct line MsgBox "This is fun")
2. Click the command button on the sheet.
Result:
3. Click on OK.
4. Next, in the Visual Basic Editor, click on Reset to stop the debugger! (More about the debugger in the next chapter) Now change the code. Excel VBA has colored the word MgBox blue to indicate the macro error.
No comments:
Post a Comment