I'm adding two VBA codes to a tab in a worksheet to either add a creation date or when something in the row is updated, add a modified date. I found the VBA code in another post and copied/pasted it into the VBA sheet. When I attempt to run it, I get a Compile Error: Ambiguous name detected. Can both sets of code exist in the same worksheet? I tried renaming the sub, but it didn't fix anything. I tried combining both codes, but it didn't produce a date in either column. Any help would be appreciated.
Code that works:
Code that doesn't work:
Code that works:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Target
Application.EnableEvents = False
If cell.Row > 1 And cell.Column > 8 Then Cells(cell.Row, "AF") = Now()
Application.EnableEvents = True
Next cell
Application.ScreenUpdating = True
End Sub
Code that doesn't work:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Target
Application.EnableEvents = False
If cell.Row > 1 And cell.Column > 8 Then Cells(cell.Row, "AF") = Now()
Application.EnableEvents = True
Next cell
For Each cell In Target
Application.EnableEvents = False
If cell.Row = 1 And cell.Column > 8 Then Cells(cell.Row, "AE") = Now()
Application.EnableEvents = True
Next cell
Application.ScreenUpdating = True
End Sub