Range in an array instead of multiple variables

nicolewh

Well-known Member
Joined
Aug 7, 2009
Messages
554
I would like to place a range (table2) in an array within a macro instead of multiple variables. Here is the macro so far:

Rich (BB code):
Sub  Test()
Dim LR As Long, i As Long
CountryColumn = xl_Col(Range("Table1[Column2]").Column)
LR = Range(CountryColumn & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    Rows(i).Hidden = IsError(Application.Match(LCase(Range(CountryColumn _
& i).Value), Array("Pink", "White"), 0))
Next i
End Sub
I would like something similar to this instead:
Rich (BB code):
Sub  Test()
Dim LR As Long, i As Long
CountryColumn = xl_Col(Range("Table1[Column2]").Column)
LR = Range(CountryColumn & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    Rows(i).Hidden = IsError(Application.Match(LCase(Range(CountryColumn _
& i).Value), Array(Range("Table2")), 0))
Next i
End Sub
(Of course above doesn't work for some reason :()
To help you better understand the variables "Pink" and "White" are included in table2. Here is table2:
Column1
Pink
White


Possible? I hope!

Thanks :)

Nicole
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Very clever coding in exhibit #1 :p

Try (untested and assuming that Table 2 is a named range)

Code:
Sub Test()
Dim LR As Long, i As Long
CountryColumn = xl_Col(Range("Table1[Column2]").Column)
LR = Range(CountryColumn & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    Rows(i).Hidden = IsError(Application.Match(LCase(Range(CountryColumn _
& i).Value), Range("Table2")), 0)
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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
Back
Top