I have created a spreadsheet which auto-fills date/time in column B when there are contents entered into column C. There is a risk however of double clicking or making changes in the cell will update the date and time, I don't want it to do this if it has already been populated.
What do I need to add to my code to stop the macro running IF the cell has contents?
This is the coding I used:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("C8:C27")) Is Nothing Then
With Target(1, -0)
.Value = Now
Checking if the cell in column B is empty before writing the date into it is fairly straightforward. Inside your
With statement just check if the value of the cell in B is blank and exit the sub if there is something in it. Otherwise run through your code to write the date to the cell.
With Target(1, -0) If .Value <> "" Then Exit Sub .Value = Now .EntireColumn.AutoFit End With