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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,304
Office Version
  1. 365
Platform
  1. Windows
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
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
59,079
Office Version
  1. 365
Platform
  1. Windows
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
 

Forum statistics

Threads
1,141,718
Messages
5,708,072
Members
421,543
Latest member
SGM

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
Top