Multisheet workbook, time stamp on active sheet in VBA

Shiro26

Board Regular
Joined
Oct 2, 2015
Messages
82
Hi

I have a workbook with three sheets named respectively A, B and C.
Each sheet is formatted the same way (same template based). Only the content changes.

I would like to write in VBA that, when a change occurs in the active sheet, the cell B1 which is the date, changes to the current date/time (timestamped)

I tried to used that code below but when I make a change in the sheet A, the timestamp is updated in the three sheets
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
cells(1,2) = Now()
End Sub

Therefore, how can I make the code change the timestamp only for the active sheet and not each sheet's?

Thank you in advance for your help

Shiro
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
This script your showing will only enter the time stamp in the sheet you put this in.''

It will not change anything in the other sheets.

Maybe you installed this same script in all your sheets.
 
Upvote 0
Hi,

thnak you for the reply,

Unfortunately, no.

I have made already different tests.

1 workbook, 3 sheets (A,B,C).
The 3 sheets are blank/empty

I have pasted the code in sheet A.
> When I make a change in sheet B, sheet A remains blank and empty
> when I make a change in sheet A, sheet A is time stamped

Then I have pasted the code in THEWORKBOOK
> when I make a change in sheet B, the date already stamped in A did not change and there is not date stampled in sheet B, no date stamped in sheet C.

Then I have pasted the code in sheet C
> when I make a change in sheet C, the sheet C becomes timestamped AND the date already timestampled in sheet A changes also.
> when I make a change in sheet B, the date in sheet A and sheet C do not change.

This is why I am a bit confused... with how to write properly this supposedly simple code... so that, the date in sheet A is changed only when sheet A is processed.

Best,

Shiro
 
Upvote 0
So you want this script to apply to all sheets.

If you make a change in any sheet you want a time stamp in that sheet.
If this is correct you put your script into "ThisWorkbook" only

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Cells(1, 2) = Now()
End Sub

OK
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,405
Members
449,157
Latest member
mytux

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