Advance filter using an array for the criteriaSet matrices = .Range(matrix, .Cells(.Rows.Count, matrix.Column).End(xlUp))

Luin29

New Member
Joined
Oct 7, 2015
Messages
45
Hi everyone. I hopefully have a quick question that can be answered: How do I use Excel's advance filter with an array value for the criteria?

Here is part of my code so far (the last line is the where I am currently stumped at):

Rich (BB code):
With Sheets("temp")
    Set matrices = .Range("B2", .Cells(.Rows.Count, matrix.Column).End(xlUp))
End With 
  
    matrices.AdvancedFilter Action:=xlFilterInPlace, Unique:=True
    ReDim M_array(1 To matrices.SpecialCells(xlCellTypeVisible).Row)
    For Each c In matrices.SpecialCells(xlCellTypeVisible)
        If c.Value <> "Matrix" Then
            M_array(i) = c.Value
            i = i + 1
        End If
    Next c
    ActiveSheet.ShowAllData
.
.
.
    For m = LBound(M_array) To LBound(M_array)
    If CountUnique(Range(units_c.Offset(1), Cells(Rows.Count, units_c.Column).End(xlUp))) > 1 Then
        answer = MsgBox("More than one type of " & M_array(m) & " units reported. Do you want to convert the units?", vbYesNo + vbQuestion, "Multiple Units")
        Select Case answer
            Case vbYes
            UserForm16.Show
            matrices.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=M_array(m), Unique:=True
<strike>
</strike>


Thanks for any and all of the help.
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi

The CriteriaRange, like the name says, must be a range, not an array.

You can write the array into a range and then use the Advanced Filter with that range.
 
Upvote 0
Thanks pgc01. I should have thought on that question a bit more before posting. Figured out that I needed to use Autofilter with transpose(array) for the criteria.
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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