Regarding AutoFilter field

Mangolili

Board Regular
Joined
Jun 21, 2011
Messages
54
w.Range("A1").AutoFilter field:=2, _
Criteria1:=CStr(availableFilters(currentFilterIndex))

How can i make the autofilter field more dynamic, not referring to specifically column to, but any column?:confused: Please help! Thank you so much.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You would still need to specify the field Number.

Code:
Dim FieldNum As Long

FieldNum = Application.InputBox(Prompt:= _
                "Please Enter the Number of the column that you wish to Filter.", _
                    Title:="SPECIFY COLUMN", Type:=1)
If FieldNum > 0 Then
w.Range("A1").AutoFilter field:=FieldNum, _
Criteria1:=CStr(availableFilters(currentFilterIndex))
End If
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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