Hi I would like to connect 2 separate things into one worksheet_change (better than double click). I am a little green yet so could You please help me out guys?
I tried "else" and "else if" , didnt work out. Thanks in advance
I tried "else" and "else if" , didnt work out. Thanks in advance
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rInt As Range
Dim rCell As Range
Dim tCell As Range
Set rInt = Intersect(Target, Range("D: D"))
If Not rInt Is Nothing Then
For Each rCell In rInt
Set tCell = rCell.Offset(0, 1)
If IsEmpty(tCell) Then
tCell = Now
tCell.NumberFormat = "hh:mm"
End If
Next
End If
End Sub
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
Dim rInt As Range
Dim rCell As Range
Dim tCell As Range
Set rInt = Intersect(Target, Range("B:B"))
If Not rInt Is Nothing Then
For Each rCell In rInt
Set tCell = rCell.Offset(0, 1)
If IsEmpty(tCell) Then
tCell = Now
tCell.NumberFormat = "hh:mm"
End If
Next
End If
End Sub
Last edited by a moderator: