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

Colin Legg

MrExcel MVP, Like totally RAD man
Joined
Feb 28, 2008
Messages
3,497
Following on from the Personal.xls poll, I thought it would be interesting to gauge how many VBA'ers on this board use Option Explicit to enforce variable declaration.

I thought there might be a trend relating to how long peeps have been coding in VBA so I've broken the poll into categories depending on VBA experience - I'll leave it to you to decide which experience bucket you belong in. Sorry if the number of choices on the poll is a bit daunting.

When you vote, if you want to post too to explain why you do or don't use it then that'd be interesting.
 
Last edited:

TinaP

Well-known Member
Joined
Jan 26, 2005
Messages
522
I prefer declaring all my variables just to keep everything neat and tidy. My programming instructors would be so proud.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,327
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
First thing you should do in the VBE is turn off auto syntax check and turn on required variable declarations. :) (second thing is to install MZ Tools of course)
 

Atroxell

Active Member
Joined
Apr 18, 2007
Messages
417
I have learned in the last couple of years that it is far easier to turn on Option Explicit and necessitate variable declaration than it is to search for the malfunction without even a clue as to why something will not work.

I also like the fact that the result is a little more efficiency in the code.
 

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,432
Definitely use Option Explicit. Prevents inadvertently miscoding variable names.
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,651
I put myself down as an advanced user who uses Option Explicit. Not sure whether advanced is strictly accurate though...

But I also used it when I was very much a beginner. In fact I think that I learned to do that even before I learned not to Select :)
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
I use Option Explicit all the time. I'm such a graet tpyist that it's worth my while...
Also, once I set the capitalisation in the variable I always type in lower case after that. Helps catch typos...

Denis
 

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,432
Also, once I set the capitalisation in the variable I always type in lower case after that. Helps catch typos...
Either great minds think alike, or fools never differ! I do exactly the same thing. If the variable doesn't auto-capitalise after I press Enter, I know I've made a tpyo.

Andrew
 

Smitty

MrExcel MVP
Joined
May 15, 2003
Messages
29,536
Also, once I set the capitalisation in the variable I always type in lower case after that. Helps catch typos...
Ditto :)

It's funny how hard it is to get some people to use it - especially some of those who have just "graduated" from the recorder and have never had a need for it ("but my code always worked up until now...")
 
Last edited:

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,118
I put myself down as an advanced user who uses Option Explicit. Not sure whether advanced is strictly accurate though..
Ditto on all fronts though unlike Peter I confess I did not use Option Explicit until around 2 years ago
(this despite having worked in default Option Explicit .net prior to that - why ? I've no idea).

As advised by R I don't use Auto Syntax - I don't think any PC/laptop of mine would last more than a day were I to leave that setting enabled
 

Forum statistics

Threads
1,081,773
Messages
5,361,198
Members
400,617
Latest member
barron1

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top