Who uses Option Explicit?

Do You Use Option Explicit When You Write VBA Code?

  • I'm an advanced VBA user and I use Option Explicit

    Votes: 29 45.3%
  • I'm an intermediate VBA user and I use Option Explicit

    Votes: 22 34.4%
  • I'm a new VBA user and I use Option Explicit

    Votes: 3 4.7%
  • I'm an advanced VBA user and I do not use Option Explicit

    Votes: 1 1.6%
  • I'm an intermediate VBA user and I do not use Option Explicit

    Votes: 5 7.8%
  • I'm a new VBA user and I do not use Option Explicit

    Votes: 1 1.6%
  • What the heck are you talking about?

    Votes: 3 4.7%

  • Total voters
    64
Voted intermediate and always use it (don't really remember ever not).

I use Ctrl+Space all the time to complete my variable names and whether I compile code before running it generally depends how I'm feeling that day.

This is a classic mistake I've seen from a few people who are pretty competent at writing VBA:

Code:
Dim lngLastRow, lngLoopRow, lngFirstRow As Long

Not that using Option Explicit makes any difference to that.

Dom
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
So who voted Advanced - No? Colin (you always vote no)?
 
I'm wondering when you going to put your vote against the "What The Heck Are You Talking About" choice, Rory?
 
For once, I think I do though. :)
 
It rubbed against the grain, but I voted yes on this poll. *cough*
 
minor tangent

On a minor tangent, I've been caught out in the past typing in directly.

range("whatever").end(xlleft)
instead of
range("whatever").end(xltoleft)

Often enough that I now know to use xltoleft :)
 
Re: minor tangent

I put intermediate, No. I don't fell that I am quite to the advanced level yet, as I have no clue where to start with API's and that sort of stuff, but I can still program a great program. And I am just too lazy to set the option to turn it on. I do comment a lot in my code and basically spell everything out in pseudo code, just neevr really felt the need to have it explicitly on. :)
 
Yep, had it on for a few years now and the "auto-syntax interrupt your copy & pasting feature" turned off.

I always forget about the Ctrl+Space bit - probably because it annoys my co-worker, who shouldn't be looking over my shoulder and getting on with his own work.

I didn't know about the variable declaration until about a year ago though, but hardly ever came across that problem as I usually put variables on different lines unless they're X, Y, Z flags, counters, whatevers.
 
Do you remember your first steps in VBA?

For me it was the playing time with VBA code examples given from anywhere.
All was ok until I’ve followed the strong suggestion to use Option Explicit statement as the default VBE setting.
As the result after such setting I’ve spent a lot of time to sort out the break reason of previously working code.

My point of view now – skipping of Option Explicit statement is the feature for beginners.
Because without OE they can concentrate on the fast way to achieve the motivation result similar to Hello world program.

Therefore, there is no Option Explicit statement in my suggestions because I know that the code could be added to the working one developed without OE.
But despite of this the suggested code is developed and debugged on my side with Option Explicit and with all variables declared.

So, should I vote for "What the heck are you talking about"? :)
 
Last edited:
I voted Intermediate - No. I know I should use OE, I just forget to. I'll try to do better, I promise!
Same here.

I really really know it should be used, but trying to do something quickly having to declare all variables becomes a chore. So I can certainly see why people don't use it.
 

Forum statistics

Threads
1,214,570
Messages
6,120,294
Members
448,953
Latest member
Dutchie_1

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