VBA - Workbook suddenly requiring all variables declared when no option explicit

BigShango

Board Regular
Joined
May 8, 2014
Messages
106
Hi,

I have a workbook that I've used for years. I know it's not best practice but the variables are not defined. This has never caused an issue, it has always worked fine, but today it is giving me a compile error on every variable unless I dim them. Option Explicit is not set, neither is the checkbox in Options.

Any idea what is going on? Why has it suddenly shat the bed today and decided it needs all variables defined? I know I could just define all the variables but there are dozens of them and it worked fine yesterday.

Thanks in advance
D
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Are you sure that the problem isn't really something else?
What is the exact error message you are getting?
What line of code does it highlight as being the problematic one?

I know I could just define all the variables but there are dozens of them and it worked fine yesterday.
"Dozens" is really not all that many. I would take the time to do it. It could help save you headaches down the road. It is worth the small amount of extra effort.
 
Upvote 0
I'm not sure what the problem is but I know what is happening.

Error is on the very first variable. I dim that then the error is on the second variable. I dim that and it's on the third and so on. It's definitely the variables not being defined that's causing it. It's the exact same errors as I would get if I put option explicit at the top of the code.

I know I can fix it by dimming them all but I'd rather find out why this spreadsheet worked fine for years without it.
 
Last edited:
Upvote 0
But what is the exact error message?
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

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