Forum

Notifications
Clear all

Update a cell automatically when changes are made to spreadsheet

3 Posts
2 Users
0 Reactions
379 Views
(@cunninghamcourt)
Posts: 2
New Member
Topic starter
 

Hello-

I have a workbook with multiple spreadsheets that is updated regularly. Each time I make changes to the workbook, I have to go to the first spreadsheet and update the version number and date in two separate cells. Is there a formula that I can use that will update these two cells each time a change is made in the workbook? 

Any help would be greatly appreciated!

 
Posted : 06/04/2019 9:34 am
(@debaser)
Posts: 837
Member Moderator
 

Do you want any manual change to increase the version number by 1 and update the date to the current date? If so, open the VB Editor (Alt+f11), locate your workbook in the Project Explorer window and double-click the ThisWorkbook object, then paste this in (and adjust the referenced cells as required):

 

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
On Error GoTo reset_events
' turn events off to prevent recursion
Application.EnableEvents = False
' assumes first sheet has the version number and date
With Sheets(1)
' version number - change range as necessary
.Range("A2").Value2 = .Range("A2").Value2 + 1
' current date
.Range("B2").Value = Date
End With
reset_events:
Application.EnableEvents = True
End Sub

 

Please note: this will be triggered by every change you make, so you might be better off with a manual routine that you run whenever  you want the version and date updated.

 
Posted : 09/04/2019 4:47 am
(@cunninghamcourt)
Posts: 2
New Member
Topic starter
 

Thank you so much!

 
Posted : 10/04/2019 10:39 am
Share: