joyacv2
asked on
FILTER ON EXCEL TABLE IN VBA
Hi,
I need a vba code to create custom filters on excel columns within a table, any idea?
BOOK2.xlsm
I need a vba code to create custom filters on excel columns within a table, any idea?
BOOK2.xlsm
Can you be a little more specific? What are you wanting to filter by? Is it always the same string, column, etc.?
ASKER
hi,
For example in the columnA in the included workbook, filters the columnA for fields that contains letter V, but using VBA not table filter options
For example in the columnA in the included workbook, filters the columnA for fields that contains letter V, but using VBA not table filter options
Are you familiar with VBA at all? You can modify the below example as needed:
Line 2 - Needs to be the name of the sheet
Line 4 - Table Header Range
Line 5 - "*V*" searches for the letter V in a string
This works as expected in the example you provided.
BOOK2.xlsm
Sub FilterCriteria()
With Sheet1
.AutoFilterMode = False
.Range("A1:D1").AutoFilter
.Range("A1:D1").AutoFilter Field:=1, Criteria1:="*V*"
End With
End Sub
Line 2 - Needs to be the name of the sheet
Line 4 - Table Header Range
Line 5 - "*V*" searches for the letter V in a string
This works as expected in the example you provided.
BOOK2.xlsm
ASKER
Hi,
I am familiar with VBA. How you specify by column name and not by range, this is because in my code the table can start in any cell and can be any number of fields in it?
I am familiar with VBA. How you specify by column name and not by range, this is because in my code the table can start in any cell and can be any number of fields in it?
joyacv2,
Can you please be more specific on how the table will start in any cell? Do you mean by it can start in any column or do you mean it can start randomly in any place on the worksheet?
Can you please be more specific on how the table will start in any cell? Do you mean by it can start in any column or do you mean it can start randomly in any place on the worksheet?
ASKER
hi,
for example, the columnA of the table can be in the cell c3 or any other
for example, the columnA of the table can be in the cell c3 or any other
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
exellent, perfect!!!!