VBA assist

onejay

New Member
Joined
Mar 29, 2023
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hello. I am trying to create an Excel document that can record a running list of each change to a particular cell. I'm using the below VBA formula, but the problem I'm running into is that when I close out and reopen the document, the list of changes resets. So basically, I'm looking for a way to save every change no matter how many times the document is opened or closed. Thank you for any assistance.

Dim xVal As String
Private Sub Worksheet_Change(ByVal Target As Range)
Static xCount As Integer
Application.EnableEvents = False
If Target.Address = Range("B3").Address Then
Range("A6").Offset(xCount, 0).Value = xVal
xCount = xCount + 1
Else
If xVal <> Range("B3").Value Then
Range("A6").Offset(xCount, 0).Value = xVal
xCount = xCount + 1
End If
End If
Application.EnableEvents = True
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,
Just make sure your cell A5 is holding something
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Target.Address <> "$B$3" Then Exit Sub
' Make Sure Cell A5 is holding something ''''''''''''''''''''
Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = Target.Value
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,822
Messages
6,181,165
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