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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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