VBA code to filter hidden column

HMDurham

New Member
Joined
Jun 9, 2015
Messages
4
Hello! I'm not very good with VBA code so I was wondering if someone could assist me? I have a worksheet with States that are repeated for various rows listed in Column A. Columns B through K have further information that corresponds to each row in Column A. I have each State listed only once in a combobox at the top of the spreadsheet. What I would like to do is hide column A and run a code that would filter the hidden column based on the matching combobox selection. For example, if Alabama is selected in the combobox than the report would filter to show only those rows that correspond to Alabama in column A.

StateID#Location
Alabama6566Wilhelm
Alabama6576Huntsville
Maryland6689Market St
Maryland6888Bypass Lane

<tbody>
</tbody>

Thank you in advance for assisting me!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try this on combobox change event

Code:
Private Sub ComboBox1_Change()
    With ActiveSheet
        .AutoFilterMode = False
        .Range("A1:K1").AutoFilter
        .Range("A1:K1").AutoFilter Field:=1, Criteria1:=ComboBox1.Text
    End With
End Sub
 
Upvote 0
Never mind. I figured out what I was doing wrong. Thank you so much for the code! It is working out beautifully. :)
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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