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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,215,332
Messages
6,124,314
Members
449,153
Latest member
JazzSingerNL

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