'Variable Not Defined' error... even though it is(?) Same code worked yesterday... now no control types (or other) are working ????

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
476
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Yesterday, everything worked fine. Today, now I get the same error on every control I select.

I also tried a completely separate workbook (nothing in common with the first except both use VBA) and got the same error! :confused:

The only change I made yesterday to bothwork books was adding in some protection stuff, but all was working fine, and now... not.

I went back to a version from the previous day from that (so 2 days ago) and it works fine. Examined the code from both... and aside from the changes yesterday, both are the same.

So... I copied all the code over to a Word document that I have a macro set up so I can make quick changes to certain words/lines of code (been using it for months now and its not done anything that didnt copy over to excel just perfectly) and I removed all the protection stuff code from yesterday (entered a " ' " at the begininng of each line).. and... no improvement. Same 'Variable Not Defined' error... huh?

Anyone seen or heard of this before... (ms.google was of absolutely no help to me lol)
Here is the error, and some of the code, and you can see my " ' " that was inserted at the beginning of all code that I had added yesterday.

15z1b9e.jpg
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
PS- I did all the normal 're-start your computer' stuff (disconnecting from network, etc) and no dice.
Going to go try it on someone elses workstation to see how it behaves there :banghead:
 
Upvote 0
Change events do not have a Cancel argument. Hence the error
That said, what is the point of have either the change or doubleclick events when they aren't doing anything?
 
Upvote 0
Yes, I see that. That was done in haste (as I was going through changing all of the previous days changes by putting a " ' " in front of them. I neglected to just remove all the code for that change event like I should of. Thanks Fluff
 
Upvote 0
Here is what I get once I removed that change (and other similiar) events:

33adrbl.jpg
 
Last edited:
Upvote 0
Oops... you cannot see it as when I hit 'print screen' to take the screen shot it didnt capture the highlighted VBA code that its saying is not defined... its the " lCol " (the first one it comes to)
 
Last edited:
Upvote 0
That's because you haven't declared rcol, only lCol
 
Last edited:
Upvote 0
I confirmed that the same workbook/file (as saved on our network) opens and runs fine on a different workstation. ?????
 
Upvote 0
I saw that too. But if I Dim that it still comes up. I went and added a " ' " before all the code with rCol and lCol and ran it and then it gave me the same error but this time highlighted "Cell" where it states "For Each Cell"right beneath it.

I just compared all the code from 2 days ago to yesterdays (2 days ago is working) and aside from the protection stuff I added yesterday, all of it is the same. Line for line.
 
Upvote 0
I suspect that the main difference between the old & new files is Option Explicit which you can see at the top of the first image you posted.
This forces you declare all your variables & is well worth doing, even though it may seem like a pain to begin with.
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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