Michael151
Board Regular
- Joined
- Sep 20, 2010
- Messages
- 247
Hello all,
Having trouble modifying my VBA code to find multiple columns. In the code below, if the column "sales set" contains the word "SOLD" then the column "exclusive" is filled with a color, in this case gray. How would I modify the code to include multiple columns filled with color? (such as "exclusive2", "exclusive3", etc.). I've tried using an Array without any luck.
Help is most appreciated!
Dim ju As Long, kw As Long, cgfind As Range
Dim mh As Long, np As Long
Set cgfind = ActiveSheet.Cells.Find(What:="sales set", LookAt:=xlWhole)
ju = cgfind.Column
Set cgfind = ActiveSheet.Cells.Find(What:=("exclusive"), LookAt:=xlWhole)
kw = cgfind.Column
mh = Cells(Rows.Count, ju).End(xlUp).Row
For np = mh To 2 Step -1
Cells(np, ju).Select
If Cells(np, ju) = "SOLD" Then
Cells(np, kw).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If
Next np
Having trouble modifying my VBA code to find multiple columns. In the code below, if the column "sales set" contains the word "SOLD" then the column "exclusive" is filled with a color, in this case gray. How would I modify the code to include multiple columns filled with color? (such as "exclusive2", "exclusive3", etc.). I've tried using an Array without any luck.
Help is most appreciated!
Dim ju As Long, kw As Long, cgfind As Range
Dim mh As Long, np As Long
Set cgfind = ActiveSheet.Cells.Find(What:="sales set", LookAt:=xlWhole)
ju = cgfind.Column
Set cgfind = ActiveSheet.Cells.Find(What:=("exclusive"), LookAt:=xlWhole)
kw = cgfind.Column
mh = Cells(Rows.Count, ju).End(xlUp).Row
For np = mh To 2 Step -1
Cells(np, ju).Select
If Cells(np, ju) = "SOLD" Then
Cells(np, kw).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If
Next np