Array Formula to Find Multiple Columns

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
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,141,015
Messages
5,703,746
Members
421,312
Latest member
Mooncake1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top