View Single Post
 
Old 06-18-2013, 02:21 PM
fumei fumei is offline Windows 7 64bit Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

1. Option Explicit should only be used onbce, and it should be at the very top (beginning).

2. Once you have other Subs in the module, declarations (Dim Blah as Yadda) should be IN a Sub - i.e within a Sub.....End Sub.

Public declarations (Dim Blah as Yadda) should be at the top, right after Option Explicit. I suspect that those declarations from Greg's site apply to the a Sub, and should be within the Sub.....End Sub.

Option Explicit in a module requires you to make declarations. This is a GOOD idea. You can have VBA insert it automatically for new modules by going Tools > Options and on the Editor tab check Require Variable Declaration.

So. Move Option Explicit to the top of the module. Move the declarations between a Sub and End Sub.
Reply With Quote