Jagat Pavasia
Active Member
- Joined
- Mar 9, 2015
- Messages
- 406
- Office Version
- 2021
- Platform
- Windows
I have VBA below
I want only date but in this vba code date and time display,
please help to only date
VBA Code:
Sub Macro2(Target As Range)
Dim WorkRng As Range
Dim rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("C6:C36"), Target)
xOffsetColumn = -2
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
On Error GoTo exit_proc
Me.Unprotect
For Each rng In WorkRng
If Not VBA.IsEmpty(rng.Value) Then
rng.Offset(0, xOffsetColumn).Value = Now
rng.Offset(0, xOffsetColumn).NumberFormat = "dd/mm/yyyy"
Else
rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
Application.EnableEvents = True
End If
exit_proc:
Me.Protect
End Sub
I want only date but in this vba code date and time display,
please help to only date