The Object code has suddenly stopped working in one of my spreadsheets

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
232
Office Version
  1. 365
Platform
  1. Windows
The following is in the appropriate Worksheet Object:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Stop
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     Stop
End Sub
When I change a value in a cell or change the cell to be selected in that Sheet, I get the "STOP's" indicated in the code.

My problem is that in another spreadsheet, I am depend on the same Object code working, but it is "turned off": ie. the code I expect to work is never started..
Any idea why it is turned it off and what I can do to turn it back on.

Thank for any help, Mac
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You can only turn such things on or off at application level, if it is working in one then it should work in the other.

The most likely thing is that it is not in the correct module or that there is a slight error in the name which is invalidating it.

VBA Code:
Application.EnableEvents = True
in the immediate window will turn them back on if you have inadvertently turned them off.
 
Upvote 0
Also have a look at events being disabled at some point in other codes and not being returned to true.
To rectify this, simply put
VBA Code:
 Application.enableEvents=True
in the Immediates window and press Enter
 
Upvote 0
That was the first thing I looked at. It still doesn't work.

But thanks for reading this.
Mac
 
Upvote 0
What other code have you got. In particular look in the ThisWorkbook module.
 
Upvote 0
And this works on other spreadsheets.
If you're using the 'Stop' test to check if it is firing and nothing happens then that points to a naming or location error, otherwise I would say that there is potential for an incorrect logical test to be bypassing the body of the code.

If you've checked that EnableEvents = True then unless you're going through the convoluted process of opening multiple instances of excel (holding the Alt key and opening excel twice) you can not disable events in a way that they will start in one workbook but not another.

As you're using worksheet events they must be in the correct worksheet module and in the correct workbook, e.g. to run on Sheet1 of Book1 the code must be in the worksheet module of Sheet1 in the Book1 project, if it is in a regular module, a different worksheet module, a workbook module, or any module in another workbook then it will not run.

Another thing that I have seen a few times is where people rename things, for example adding a number to the end if the name in order to have multiple events with the same name.
VBA Code:
Private Sub Worksheet_Change2(ByVal Target As Range)
Doing this invalidates the procedure name and prevents if from firing.
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,007
Members
448,935
Latest member
ijat

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