M
MAX
I have this code so that when I write a name in column A, the date and time
appears both in column B. All I want is that the date appears in column B and
the time in column C. Below is the code.
Thanks in advance.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRow As Long
If Target.Cells.Count > 1 Then
Exit Sub 'one cell a time
End If
If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub 'Look in column A only
End If
myRow = Target.Row
On Error GoTo ErrHandler:
With Me.Cells(myRow, "b")
If IsEmpty(.Value) Then
'ok to add, the cell is empty
Application.EnableEvents = False
.NumberFormat = "dd/mm/yyyy > hh:mm:ss"
.Value = Now
End If
End With
ErrHandler:
Application.EnableEvents = True
End Sub
appears both in column B. All I want is that the date appears in column B and
the time in column C. Below is the code.
Thanks in advance.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRow As Long
If Target.Cells.Count > 1 Then
Exit Sub 'one cell a time
End If
If Intersect(Target, Me.Range("a:a")) Is Nothing Then
Exit Sub 'Look in column A only
End If
myRow = Target.Row
On Error GoTo ErrHandler:
With Me.Cells(myRow, "b")
If IsEmpty(.Value) Then
'ok to add, the cell is empty
Application.EnableEvents = False
.NumberFormat = "dd/mm/yyyy > hh:mm:ss"
.Value = Now
End If
End With
ErrHandler:
Application.EnableEvents = True
End Sub