rdoulaghsingh
Board Regular
- Joined
- Feb 14, 2021
- Messages
- 105
- Office Version
- 365
- Platform
- Windows
I have 3 statuses in a dropdown list in Col C. namely "N/A", "Pending" and "Completed" and a date column in Col B. If the user selects N/A from the dropdown in Col C. it locks the date field to the left and provides some formatting to the field. However, if the user selects another status besides "N/A" it clears the formatting and N/A text from date field. I have the code below which does everything I need it to, except that if a date is entered into the field and then I select "completed" or "pending" it clears the field - which it shouldn't. Please help.
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Count = 1 Then
If Not Intersect(Target, Range("C3:C13,C18:C28")) Is Nothing Then
Application.EnableEvents = False
If Target.Value = "N/A" Then
With Target(1, 0)
.Value = "(N/A)"
.Enabled = False
With .Interior
.Pattern = xlLightDown
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End With
Else
With Target(1, 0)
.Value = ""
.Enabled = True
With .Interior
.Pattern = xlPatternNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End With
End If
Application.EnableEvents = True
End If
End If
End Sub