Jagat Pavasia
Active Member
- Joined
- Mar 9, 2015
- Messages
- 359
- Office Version
- 2021
- Platform
- Windows
i have VBA code, when i enter "**" i want currant date and time.
but only currant date is showing, the time is always showing 12:00 AM
please help with edit below VBA code
but only currant date is showing, the time is always showing 12:00 AM
please help with edit below VBA code
VBA Code:
Sub Macro2(target As Range)
Dim Rng As Range
If target.Count > 1 Then Exit Sub
Application.EnableEvents = False
ActiveSheet.Unprotect
Set Rng = Range("b:b,g:g,j:j,M:M")
If Not Intersect(target, Rng) Is Nothing Then
If target.Value = "**" Then target.Value = Format(Date, "dd/mm/yyyy, hh:mm AM/PM")
End If
If Not Intersect(target, Range("B4:R4")) Is Nothing Then
If target.Value = "" Then
ActiveSheet.Range("B6:R6").AutoFilter Field:=target.Column
Else
ActiveSheet.Range("B6:R6").AutoFilter Field:=target.Column, Operator:=xlFilterValues, Criteria1:=CStr(target.Value)
End If
End If
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFiltering:=True
Application.EnableEvents = True
End Sub