Please help with reading filters from another sheet

Mangolili

Board Regular
Joined
Jun 21, 2011
Messages
54
I have a spreadsheet of " n x n " columns and rows. Each column has x number of filters available to be selected. Now I can extract all available filters for one specific column (say column c1) into a separate sheet so that the new sheet ONLY contains filter A, filter B, etc for column c1 in the first column of the new sheet. How do I read the filters from that new sheet into a array? Please help, thank you.


Sub RestoreFilters()
' autofilter is already set false after redoAutofilter
' w.AutoFilterMode = False

Dim w As Worksheet
Set w = Sheets("Look Back")

' testing restore one of the filters
For i = 1 To UBound(filterArray(), 1)
If Not IsEmpty(filterArray(i, 1)) Then
w.Range("A1").AutoFilter field:=i, Criteria1:=CStr(filterArray(i, 1))
End If
Next i
End Sub
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This is the first half of the codes I have, before the codes above


'Capture AutoFilter settings
With WS.AutoFilter
currentFiltRange = .Range.Address
With .Filters
ReDim filterArray(1 To .Count, 1)
For i = 1 To .Count
With .Item(i)
If .On Then
filterArray(i, 1) = .Criteria1
If .Operator Then
MsgBox "Only one filter per column please."
Exit Sub
End If
End If
End With
Next i

For i = 1 To .Count
If filterArray(i, 1) <> "" Then
'Paste distinct column values onto Values tab
WS.Range(Cells(1, i).Address & ":" & _
Cells(1, i).End(xlDown).Address).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Sheets("Value").Range("A1"), Unique:=True
End If
Next i
End With
End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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