Separate Button for Auto Filter Selected Range

N

Nasir Naqvi

Hi,

How can we creat separate button in MS excel for selected range class in auto filter. If we click on button then only selected range class appears. Should we write script on Macro in VB.

For example,

Button Name "XYZ"

Column A (with Auto Filter)
ABC
XYZ
DEF
XYZ

If we click on button "XYZ" then cell "XYZ" instead of "ABC" & "DEF".

Regards

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
D

Don Guillett

IF? you mean that you want to filter the range by the selected column then
you would probably want a double_click event macro to do the autofilter
 
A

AndrewArmstrong

Create button using Control toolbox, right click on button and select
"view code", then enter the following

Private Sub ButtonXYZ_Click()
Columns("a:a").AutoFilter Field:=1, Criteria1:="XYZ",
visibledropdown:=False
End Sub

If you wanted to autofilter a specific range, you could replace
columns("a:a") with a range, such as range("a1:a5")
The visible drop-down is the autofilter arrow that appears in the first
cell in the range, it can be toggled on/off with true/false.

Regards,
Andrew J Armstrong
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top