Dynamic autofilter selection by using Vba

harinsh

Active Member
Joined
Feb 7, 2012
Messages
273
Hi Team,

I would like to select auto filter with dynamic content text (this will change every time but same column). This is required to integrate into in my main macro, if you can give input box where I can input the required content to filter and same should get filter in the sheet.

The number of contents also varies from time to time....for example if I want to filter content "City" and "PinCode" in given column "A". In this example it's only two contents it may go for 3 or 4 also.

Can anyone help on this.

Thanks,
 

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.
Have you tried turning on macro recording, filtering your list then looking at the code that Excel generated?
 
Upvote 0
Yes, I have done it...and not able to customise here....so, looking for help

Here is the recroding code....

ActiveSheet.Range("A:AD").AutoFilter Field:=11, Criteria1:=Array("City","Pincode"), Operator:=xlFilterValues

I would like to customise the content here which hilighed in Bold....

Let me know if you need further clarification....

thanks
 
Upvote 0
OK. So are you able to anticipate when you might have 1 value vs. 2, 3 or 4?

If not, one option might be to use the inputbox() function to get the input, and have people separate the 2, 3 or 4 values with an agreed character (e.g. put in a list like "City;Pincode"). You can then use the split() function to convert the input string into an array that can be supplied as Criteria1 in the .AutoFilter
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,429
Members
448,961
Latest member
nzskater

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