Hi,
I was wondering if it was possible to combine the date function and a time from 06:00 to 18:00 together?
This is my code:
I can get my desired result but I was wondering if it can be shortened so I could have the time included with the D1 or something similar?
Any help would be appreciated.
Thanks
Dan
I was wondering if it was possible to combine the date function and a time from 06:00 to 18:00 together?
This is my code:
VBA Code:
Sub DateandTime()
Dim D1 As Date
D1 = Date
With Sheets("Sheet1")
If .Range("A1") = D1 And Time > TimeValue("06:00:00") And Time < TimeValue("18:00:00") Then MsgBox "Yes"
End With
End Sub
I can get my desired result but I was wondering if it can be shortened so I could have the time included with the D1 or something similar?
Any help would be appreciated.
Thanks
Dan