Simple code lines failing; error 9 confusion, For without Next...with next

mikecox39

Active Member
Joined
Mar 5, 2014
Messages
251
Office Version
  1. 365
Platform
  1. Windows
I am testing; in the Immediate pane of the VBE, some of the example code in a book I am studying; in order to learn VBA.

Here are a couple that fail every time.



show.php
[/URL][/IMG]

I checked the Help option for error 9 but I didn’t understand it.

I’ve double checked the code; to make sure I entered it exactly as it is in the text, but it fails every time.

show.php
[/URL][/IMG]

This one has a "for" so why am I getting this error? Again, I double checked the example in the text and I have it written exactly as shown in the text.

Others, like “…comments.count” and “…Parent.address” work just fine.
 
There's nothing special about a temporary subroutine.

Like any other subroutine you would create it in a module, the syntax/layout is no different from a 'normal' subroutine and you can give it any name you want, as long as it complies to VBA naming rules.

As for the immediate window I don't really think it's the place for testing code.

PS You can quickly create a module by going to Insert>Module.
 
Upvote 0
Like any other subroutine you would create it in a module, the syntax/layout is no different from a 'normal' subroutine and you can give it any name you want, as long as it complies to VBA naming rules.

As for the immediate window I don't really think it's the place for testing code.
I guess I really need to get a handle on that window :banghead:

PS You can quickly create a module by going to Insert>Module.
Great, Thanks for that very helpful gem!
 
Upvote 0

Forum statistics

Threads
1,226,834
Messages
6,193,213
Members
453,780
Latest member
Nguyentam2007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top