I usually create a 'virtual' array of the table on the sheet as below and use that array to do the editing. Right now, I have an array and I want to filter it based on the first column. I also want to clear the filter after printing the filtered array. Because I will be doing this more than one time.
ReDim TableArray(LastRow, LastCol) As Variant
For i = 1 To LastRow
For k = 1 To LastCol
TableArray(i, k) = Workbooks(wb).Sheets("List").Cells(i, k).Value
Next k
Next i
I added an example table. Here is my goal:
- Filter this table (TableArray) for AA supplier.
- Then print it to the 'AA' sheet.
- After printing, clear the filter on 'TableArray'.
I searched this but the examples are usually only for 1D tables. I found this code for filtering tables but couldn't adapt it to my problem:
TableArray(lastrow,lastcol).AutoFilter field:=1, Criteria1:="AA"

TableArray(lastrow,lastcol).AutoFilter...: i suspectTableArrayis a range and not an array. You could do something similar. Apply the filter on your sheet and then copy the displayed range