VBA code just stopped working...

yoko

Active Member
Joined
Sep 5, 2006
Messages
349
I just added the code...

Code:
If Target.Address = "$A$1" Then
    Application.EnableEvents = False
    If Target.Value = 1 Then
         Range("A1").Value = "Hello world"
    Else
       Range("F10").Value = ""
    End If
    Application.EnableEvents = True
End If

Before lunch it worked fine. Now I've come back and it wont work :( I put a 1 in cell A1 and nothing happens. If I record a macro and run it, it works, but the macro above just wont work even though an hour ago it worked fine. I've not changed what I type in and macros are enabled.

Its very frustrating!! lol

Any ideas?

Cheers.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
yoko

It could be that at some point you disabled events and didn't enable them again.

Goto the VBE (ALT+F11) and enter this in the Immediate Window (CTRL+G) and press enter.
Code:
Application.EnableEvents = True
 
Upvote 0
I am betting that the code probably got interrupted along the way, so EnableEvents was turned off and not turned back on.

Run this code to turn it back on, then test again:
Code:
Sub MyTurnEventsOn()
    Application.EnableEvents = True 
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,042
Members
449,063
Latest member
ak94

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