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

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
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
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,509
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
So who voted Advanced - No? Colin (you always vote no)?
 

Colin Legg

MrExcel MVP, Like totally RAD man
Joined
Feb 28, 2008
Messages
3,497
I'm wondering when you going to put your vote against the "What The Heck Are You Talking About" choice, Rory?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,509
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
For once, I think I do though. :)
 

Colin Legg

MrExcel MVP, Like totally RAD man
Joined
Feb 28, 2008
Messages
3,497
It rubbed against the grain, but I voted yes on this poll. *cough*
 

Fazza

MrExcel MVP
Joined
May 17, 2006
Messages
9,200
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 :)
 

schielrn

Well-known Member
Joined
Apr 4, 2007
Messages
6,934
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. :)
 

Darren Bartrup

Well-known Member
Joined
Mar 13, 2006
Messages
1,258
Office Version
365
Platform
Windows
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.
 

ZVI

MrExcel MVP
Joined
Apr 9, 2008
Messages
3,658
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:

snowblizz

Well-known Member
Joined
Mar 16, 2009
Messages
1,123
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,084,878
Messages
5,380,415
Members
401,673
Latest member
Ali Balleya

Some videos you may like

This Week's Hot Topics

Top