Worksheet change event

Mr930

Well-known Member
Joined
Aug 31, 2006
Messages
585
I had some VBA code in a sub that triggered on a worksheet change event. The range I was checking was on one tab of the spreadsheet. I now want to check ranges on 8 different tabs. When I set this up, the worksheet_change() function is not called unless I change something on the original tab where it was set up. I thought the change would be caught no matter where it occurred. Is it tab specific?

thanks
Fred Emmerich
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi Fred,

Instead of using the partiticular sheet's event procedure, go to the ThisWorkbook module and try Workbook_SheetChange.

Hope that helps,

Mark
 
Upvote 0
'Fraid so. Each tab is a sheet.

You are ahead of me, I spent half a day figuring out that the macro had to be on a specific sheet instead of in a public module.

I have managed to make an event on one sheet call a public macro...perhaps you could have a 'detector' event in each sheet then one public function to do the work? Might have to pass in data.

Please let me know if you find any other useful events.

Thanks,

C.

Edit: Thanks GTO, me neither.
 
Last edited:
Upvote 0
Happy to help:-)

You can use the events related to worksheets under ThisWorkbook with the included arguments to have different things happen depending upon what sheet is firing the event. Just by example:
Rich (BB code):
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    
    Select Case Sh.CodeName
    Case "Sheet1", "Sheet2"
        MsgBox "Do something"
    Case "Sheet3"
        MsgBox "or something else"
    Case Else
        MsgBox "or some generic thing you want for any other sheet"
    End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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