D
D_Williams
Hi There!!
I really need help with this. I'm creating a spreadsheet and I'm trying to
do conditional formatting in VBA. I want it so that if I type a particular
word in one cell that it automatically colors that cell, along with two of
the adjacent cells on each side. For example, if you type "Auto" in cell C1,
it colors cells A1-E1. This is the code I'm using right now but it only
colors the cell in which I type the word in. Any help would be appreciated!!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Isect As Range
Set Isect = Application.Intersect(Range("A1:M200"), Target)
If Isect Is Nothing Then
'Do nothing
Else
Select Case Target.Value
Case "Auto"
Target.Interior.ColorIndex = 39
Case "Gas"
Target.Interior.ColorIndex = 40
Case "Income"
Target.Interior.ColorIndex = 4
Case "Rent"
Target.Interior.ColorIndex = 42
End Select
End If
End Sub
I really need help with this. I'm creating a spreadsheet and I'm trying to
do conditional formatting in VBA. I want it so that if I type a particular
word in one cell that it automatically colors that cell, along with two of
the adjacent cells on each side. For example, if you type "Auto" in cell C1,
it colors cells A1-E1. This is the code I'm using right now but it only
colors the cell in which I type the word in. Any help would be appreciated!!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Isect As Range
Set Isect = Application.Intersect(Range("A1:M200"), Target)
If Isect Is Nothing Then
'Do nothing
Else
Select Case Target.Value
Case "Auto"
Target.Interior.ColorIndex = 39
Case "Gas"
Target.Interior.ColorIndex = 40
Case "Income"
Target.Interior.ColorIndex = 4
Case "Rent"
Target.Interior.ColorIndex = 42
End Select
End If
End Sub