Macro to filter columns based in table of fields

Anka

New Member
Joined
Oct 20, 2012
Messages
45
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Hello everybody,

Well, I will try to explain in more detail.

In Sheet 1, I have data starting with row 21 (rows grow every day because new rows are added).
Based on these data I have three tables that do some calculations. (U2:AA13, AD2:AK13, AT2:AY2)

In Sheet 2 columns B to M, I have a table of fields that need to be filtered. One of the big issues is that this table can reach more than 5,000 combinations of fields.
In column A, I have some kind of code for each field's combination.

I need a macro to filter columns (in Sheet1) based on combination of fields what I have in all rows in that table.

After each filter is applied, the macro, must copy these three tables and paste them into Sheet 2 starting with cell Q1, one below the other.
In front of each copied table (in column P) should be placed the filter code that was applied.
English is not my home, and I have great difficulty explaining better what you want, but if you have any questions, I will try to answer.

Thank you in advance.

EDIT: I upload here a dummy example of what i need.



PS:Why I can not post attachments ?
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
In other words...
Dear Macro. It is possible to filter the fields you will find in that's strings, please !?

fields_excel.jpg
 
Upvote 0
This is possible ?

Code:
Sub Example()
Dim lastRow As Long
With ActiveSheet
    lastRow = Range("A" & Rows.Count).End(xlUp).row
    ActiveSheet.Range("A20:DG" & lastRow).AutoFilter [B]Field:[/B]=[B][COLOR=#ff0000]"The fields that meet in that particular range"[/COLOR],[/B] Criteria1:="<>"

End With
End Sub

The criteria is the ("<>") same for all.
 
Upvote 0
I found one million examples to select multiple criteria (from a specific list, row, or table), but not to select multiple fields from an range...
Is it so difficult what I ask?
 
Upvote 0
I found this.
Now how can I turn this array into range.

Code:
Sub Example()

Dim lastRow As Long
[COLOR=#ff0000]arr = Array(11, 17, 19)[/COLOR]

With ActiveSheet
    lastRow = Range("A" & Rows.Count).End(xlUp).Row
    ActiveSheet.Range("A21:AL" & lastRow).AutoFilter Field:=[COLOR=#ff0000][B]arr[/B][/COLOR], Criteria1:="<>"

End With
End Sub
 
Upvote 0
And if I try to put the filtering fields into a single cell

fields.jpg
 
Upvote 0
Good morning !!
All the gurus in this forum disappeared !?
Unbelievable !
 
Upvote 0
Good morning !
Maybe today is my lucky day! :biggrin: Who knows!?
 
Upvote 0
Good morning !
Maybe today is my lucky day! :biggrin: Who knows!?
I like your optimism.
How about this
Code:
Sub Example()

    Dim Arr As Variant
    Dim Val As Variant
    Dim lastRow As Long
    Arr = [COLOR=#ff0000]Sheets("Master").Range("F1").Value[/COLOR]
    
    With ActiveSheet
        lastRow = Range("A" & Rows.Count).End(xlUp).Row
        For Each Val In Split(Arr, ",")
            .Range("A21:AL" & lastRow).AutoFilter Field:=CLng(Val), Criteria1:="<>"
        Next Val
    End With
    
End Sub
Change the part in red to match your data.
Data entered as

Excel 2013 32 bit
F
111,17,19
Master
 
Upvote 0

Forum statistics

Threads
1,215,353
Messages
6,124,462
Members
449,163
Latest member
kshealy

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