Hi all,
I have the below VBA code and I'm looking to amend it so that when the end user closes the workbook, it will copy a specific cell and paste it in the next blank spot in a column.
In this case, I want it to copy cell F4 and paste it in the next blank cell in column B. The VBA code will then add the date that number was entered.
Bonus points if you're able to make it so that it does NOT copy if the number has not changed!! That would result in a bunch of unnecessary data points (trying to track the date the number changes).
Here's the code that adds the date to the non-blank cell:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B1:B100")) Is Nothing Then
With Target
If .Offset(0, -1) <> "" Then GoTo ws_exit
If .Value <> "" Then
.Offset(0, 1).Value = Format(Now, "m/d/yyyy")
End If
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
I've attached a sample workbook. The proof would be to change the number in F4 (yellow), close the workbook, open it, and the next cell will be filled in in Column B. Ideally then, if you don't change the number, save it, close it, open it, it would not have added the next since the number did not change.
Thanks in advance!
Bookmarks