PDA

View Full Version : Automatically updating date cell unless row is blank



mykal66
02-17-2020, 03:13 AM
Hi again folks, stuck again if anyone can help please?

I have a workbook that people are supposed to add the date any changes were made in a row but they never do so i have used VBA to automatically update the date when data is changed in the row - code below.

This works fine until another event moves the row data from one tab to another (deleting the original row), this still triggers the date in column D leaving the row with just a date in column D as everything has been moved to another tab.

Is there a way to adapt this code to only trigger if there is still date data in the row or use a column as a trigger e.g. Column A would always have a date in it so of the row is moved the Cell in Column A would be blank so Column D doesn't need a date

Thanks

Mykal




Private Sub Worksheet_Change(ByVal Target As Range)Application.ScreenUpdating = False


If Target.Row = 1 Then Exit Sub
Application.EnableEvents = False
Cells(Target.Row, "D").Value = Date
Application.EnableEvents = True
End Sub

SamT
02-17-2020, 10:50 AM
If Target.EntireRow.Count = 1 then
'D = ""
Exit Sub
Else
'D = Date
End If

mykal66
02-18-2020, 02:05 AM
Hi Sam

Thank you very much. It didn't work but i am going to just pull the last updated column from the workbook this time. Thanks again. Maykal