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
Joined
Feb 28, 2008
Messages
3,507
Office Version
  1. 365
Platform
  1. Windows
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:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I prefer declaring all my variables just to keep everything neat and tidy. My programming instructors would be so proud.
 
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)
 
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.
 
Definitely use Option Explicit. Prevents inadvertently miscoding variable names.
 
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 :)
 
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
 
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
 
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:
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,223,769
Messages
6,174,418
Members
452,563
Latest member
mvdk

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