T
Thomas Toth
Hi,
I'm trying to use a case list for conditional formating and thereby I'm
getting stuck with the syntax of the case conditions. Maybe someone
could point out why they don't work.
Here's what I have:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim IntColour As Integer
If Not Intersect(Target, Range("D9:Z14")) Is Nothing Then
Select Case True
Case Target = "c", "C"
IntColour = 50
Case Target Like "??"
IntColour = 3
Case Target = 1 To 9
IntColour = 54
Case Else
IntColour = 15
End Select
Target.Interior.ColorIndex = IntColour
End If
End Sub
The selection with 'Like' works fine, the others fail.
- Why does the one with the "c","C" not work? It works when I only have
"c", and it doesn't like OR either.
- Why doesn't the 1 To 9 work either? It works for 1 but not for the
other numbers.
Any help is appreciated.
Thanks a lot,
Thomas
I'm trying to use a case list for conditional formating and thereby I'm
getting stuck with the syntax of the case conditions. Maybe someone
could point out why they don't work.
Here's what I have:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim IntColour As Integer
If Not Intersect(Target, Range("D9:Z14")) Is Nothing Then
Select Case True
Case Target = "c", "C"
IntColour = 50
Case Target Like "??"
IntColour = 3
Case Target = 1 To 9
IntColour = 54
Case Else
IntColour = 15
End Select
Target.Interior.ColorIndex = IntColour
End If
End Sub
The selection with 'Like' works fine, the others fail.
- Why does the one with the "c","C" not work? It works when I only have
"c", and it doesn't like OR either.
- Why doesn't the 1 To 9 work either? It works for 1 but not for the
other numbers.
Any help is appreciated.
Thanks a lot,
Thomas