Originally Posted by
snb
Post a sample file.
Are you famliiar with dynamic tables (Listobjects in VBA) ?
You can simply copy any filtered table to a new location.
in VBA
Sub M_snb()
with sheet1.listobjects(1).range
.autofilter 2, array("1583-4410","1583-4440","1610-1010"),7
.copy sheet2.cells(1)
.autofilter
end with
End Sub
I've managed to make a checklist with the yes/no options. Thanks for the idea though! For the ones interested:
I created an input table for the user like this:
Include? |
Account Code |
Account Description |
Yes |
1583-4410 |
LC Account-in-Transit 1 |
Yes |
1583-4440 |
LC Account-in-Transit 4 |
Yes |
1610-1010 |
Tenant - Accounts Receivable - (curr) 1 |
No |
1610-1020 |
Tenant - Accounts Receivable - (curr) 2 |
With the following code I was able to export this from the input table (D17) to the export table (J17, with criteria table (d14):
Include?
Yes
I hid these two rows and now it will always filter on yes.
Code is below:
sub export()
Dim rgData As Range, rgCriteria As Range, rgOutput As Range
Worksheets("Accounts").Range("J17:M2000").ClearContents
Set rgData = ThisWorkbook.Worksheets("Accounts").Range("D17").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Accounts").Range("D14").CurrentRegion
Set rgOutput = ThisWorkbook.Worksheets("Accounts").Range("J17")
rgData.AdvancedFilter xlFilterCopy, rgCriteria, rgOutput
end sub
Thanks guys.