Timestamp (VBA) when a cell containing a formula changes - Error

KillerQueen

New Member
Joined
Dec 29, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello!

I have an excel file containing a collection of costs and what I would like to do is to have a timestamp updated in cell B2, whenever the total sum of cost is updated in B4. B4 contains a SUMIFS formula to add all the information entered in that sheet. Now I searched highs and lows for a VBA code since im not good at it, and while i managed to get some of them to work, excel cannot seem to recognize whenever the sum changes - without me somehow manually clicking on cell B4.

Anyone that has any idea on how to get this to work?

This was the latest code I got to print a date; A timestamp would be nice as well but I'm more concerned with the fact that im referencing a cell that contains a formula which seems to be an issue.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("B4")) Is Nothing Then
With Range("B2")
.Value = Date
.EntireColumn.AutoFit
End With
End If
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Okay, I gave it some thought and figures i'd be better of referencing another range that would be updated as well - however im struggling to get the time, I get a correct date but no time - anyone that could help a bit?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("F14:F53")) Is Nothing Then
With Range("B2")
.Value = Format(Now, "mm/dd/yyyy, hh:mm")
.EntireColumn.AutoFit
End With
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,120
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