I am new to using VBA but have some coding in my background.
I am trying to use this code below so that as I change a cell the date changes to the current change and this works well.
- Private Sub Worksheet_Change(ByVal Target As Range)
- 'Update 20140722
- Dim WorkRng As Range
- Dim Rng As Range
- Dim xOffsetColumn As Integer
- Set WorkRng = Intersect(Application.ActiveSheet.Range("I:I"), Target)
- xOffsetColumn = 7
- If Not WorkRng Is Nothing Then
- Application.EnableEvents = False
- For Each Rng In WorkRng
- If Not VBA.IsEmpty(Rng.Value) Then
- Rng.Offset(0, xOffsetColumn).Value = Now
- Rng.Offset(0, xOffsetColumn).NumberFormat = "mm/dd/yyyy"
- Rng.Offset(0, xOffsetColumn).ClearContents
- End If
- Application.EnableEvents = True
- End If
However, I don't want this date entry to populate when I create new entries. What is the best was to modify this code to do that? Here is some background on the issue:
In Column A it has the date the entry was added. This has 2 different entries: The actual date it was entered, and "Original" if it was there prior. Is there a way to only run this if the value in the corresponding row in Column A is < Current date or original?
I tried to play around with this but since it's running as a range I don't have the background to understand the proper way to fix this.
Any help would be much appreciated! Thank you!