Applying Worksheet_Change to lots of sheets

crocodile

New Member
Joined
Mar 15, 2019
Messages
8
Hello all,

I have a workbook in which there are a large number of sheets - most of which are "Person Sheets" - duplicates of the same sheet, containing data about various people. You can differentiate the "person sheets" from the other sheets as they have an x in cell B1.

Anyway, I need to add a Worksheet_Change procedure to the people sheets - if someone's sheet is changed, the "Last Update" timestamp on the sheet is updated to the current date, nothing complicated.

I know I can put the same Worksheet_Change procedure into each sheet - but this feels like a hugely laborious way of doing it. Is there a way of doing this "centrally"?

Many thanks and very best regards

Bazil
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
You can use a
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

End Sub
procedure in the ThisWorkbook module.
And check if the sheet name is a "Person" sheet
 
Upvote 0
Thanks Fluff,

I knew there would be a simple answer!

I've got it working (and it's still simple - so that I can understand it!):

Code:
'Whenever a change is made on one of the people sheets, the timestamp on the sheet will be updated.
'
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)


    If Sh.Range("B1").Value = "x" Then


        Application.EnableEvents = False
    
        '   Set the current date into the timestamp field
            Sh.Range("Q1").Value = Date
        
        Application.EnableEvents = True
    
    End If


End Sub

Many thanks for your help - that's exactly what I was looking for.

Bazil
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,138
Members
453,021
Latest member
Justyna P

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