Can't seem to find an answer to what I think is a relatively simple query....
I'm currently using this code to 'conditionally format' a range of cells containing various text strings...
Just wondering if there's a way to use a wildcard so if someone types "Leave - Spain" it still uses icolor 8...
I was thinking this might have worked - the old * wildcard trick but alas no:
Or even using a LEFT function
All help warmly received.
Ta
Poo
I'm currently using this code to 'conditionally format' a range of cells containing various text strings...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
Dim colorr As Integer
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("M2:IV1243")) Is Nothing Then
Select Case Target
Case ""
icolor = 46
Case "On Site"
icolor = 38
Case "On Site - am"
icolor = 38
Case "On Site - pm"
icolor = 38
Case "On Site(?)"
icolor = 40
Case "B.Hol"
icolor = 5
colorr = 6
Case "Int. Meeting"
icolor = 43
Case "Ext. Meeting"
icolor = 45
Case "Leave"
icolor = 8
Case "Leave(?)"
icolor = 34
Case "MP Training"
icolor = 39
Case "Medical/Dental"
icolor = 50
Case "Ext. Training"
icolor = 44
Case "Sick"
icolor = 12
colorr = 6
Case "Leave (1/2)"
icolor = 8
End Select
Target.Interior.ColorIndex = icolor
Target.Font.ColorIndex = colorr
End If
End Sub
Just wondering if there's a way to use a wildcard so if someone types "Leave - Spain" it still uses icolor 8...
I was thinking this might have worked - the old * wildcard trick but alas no:
Code:
Case "Leave*"
icolor 8
Or even using a LEFT function
Code:
Case Left("Leave", 5)
icolor 8
All help warmly received.
Ta
Poo