Jagat Pavasia
Active Member
- Joined
- Mar 9, 2015
- Messages
- 359
- Office Version
- 2021
- Platform
- Windows
Hi,
I have VBA code :
I want to edit this VBA code that if I type "**" in C:C then it should be auto type "NIGHT",
and if I type "**" in D:D then it should be auto type "DAY"
please give me VBA with edited
I have VBA code :
VBA Code:
Private Sub worksheet_change(ByVal Target As Range)
Dim rng As Range
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
ActiveSheet.Unprotect
Set rng = Range("C:C")
If Not Intersect(Target, rng) Is Nothing Then
If Target.Value = "**" Then Target.Value = Format(Date, "mm/dd/yyyy")
End If
If Not Intersect(Target, Range("A4:K4")) Is Nothing Then
If Target.Value = "" Then
ActiveSheet.Range("A6:K6").AutoFilter Field:=Target.Column
Else
ActiveSheet.Range("A6:K6").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
I want to edit this VBA code that if I type "**" in C:C then it should be auto type "NIGHT",
and if I type "**" in D:D then it should be auto type "DAY"
please give me VBA with edited