VBA - How to create buttons/dropdowns that filter data in rows

LNG2013

Active Member
Joined
May 23, 2011
Messages
466
Hello!

In VBA how can I make some dropdown selectors to help filter data sets? That can then be used in calculations.

The table is on sheet2, Column A is names, Column B is months. I want to give the user the ability to select a name from the choices in column A and then select the month for the data set in column B.

The big trick is that there might be several entries for the same person in the month. So it will need to select all data entries for "Bob" in "October." I could then have calculations for averaging all of the data sets in columns C fot the user and add all the data sets from column D together for the sum?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
One way:

Code:
Sub QuickAutofilter()
    With ActiveCell
        If Not .Worksheet.AutoFilterMode Then .AutoFilter
        .CurrentRegion.AutoFilter Field:=.Column - .CurrentRegion.Column + 1, _
                                  Criteria1:=.Value
    End With
End Sub

Assign a convenient shortcut. Select a cell in one column, run the code, select a cell in another column, run the code.
 
Upvote 0
Hey shg, I am trying to set this up as an easy interface for other staff... and don't want them to manipulate the data directly.

What I am looking for I guess, is a script that will automatically select column A, turn on filtering, and in a dropdown in sheet1 show the results for them to select from. So let's say they select Bob in this dropdown, in the second dropdown there will be a list of months for Bob based on the data sets, the user can then select one of those months. Which then will further filter the data results.
 
Upvote 0
and in a dropdown in sheet1 show the results for them to select from. So let's say they select Bob in this dropdown, in the second dropdown there will be a list of months for Bob based on the data sets
With the exception of turning AutoFilter on to begin with, that's how AutoFilter works ...
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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