Hello all, I'm new here and need a bit of help please (new to VBA Excel)
I'm trying to get the following code to work but cant work out how to go from one stage to the next
Would be very greatful of any help give........thanks in advance
Mark
I'm trying to get the following code to work but cant work out how to go from one stage to the next
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'First name entry (cell D), time & date auto entered (cell A & B)
Dim A As Range, B As Range, Inte As Range, r As Range
Set A = Range("D:D")
Set Inte = Intersect(A, Target)
If Inte Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each r In Inte
If r.Value > 0 Then
r.Offset(0, -3).Value = Date
r.Offset(0, -3).NumberFormat = "dd-mm-yyyy"
r.Offset(0, -2).Value = Time
r.Offset(0, -2).NumberFormat = "hh:mm:ss AM/PM"
Else
r.Offset(0, -3).Value = ""
r.Offset(0, -2).Value = ""
End If
Next r
Application.EnableEvents = True
End Sub
'Second name entry (cell I), time & date auto entered (cell G & H)
Dim G As Range, H As Range, Inte2 As Range, r2 As Range
Set G = Range("I:I")
Set Inte2 = Intersect(G, Target)
If Inte2 Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each r2 In Inte2
If r2.Value > 0 Then
r2.Offset(0, -1).Value = Date
r2.Offset(0, -1).NumberFormat = "dd-mm-yyyy"
r2.Offset(0, -2).Value = Time
r2.Offset(0, -2).NumberFormat = "hh:mm:ss AM/PM"
Else
r2.Offset(0, -1).Value = ""
r2.Offset(0, -2).Value = ""
End If
Next r2
Application.EnableEvents = True
End Sub
Would be very greatful of any help give........thanks in advance
Mark