use the value chosen from a selection in a combobox and use it for selection in filtering rows

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
476
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I have a combobox that is referencing a long list on a separate workskeet (sheet3) and I want to use the name for what the user chooses and hide all rows that do NOT contain that name/value from a column... Basically, I am wanting to use VBA/activeX with a combobox to do the same thing as filtering

So if "Spray & Forget" is chosen from the list it will filter out everything from the 'customer' column in G that isnt "Spray & Forget".

e01to3.jpg




My code I have so far: (its incomplete and wrong, I know... still very much greeen when it comes to VBA :( )

Code:
Private Sub ComboBox1_Change()    

Range("H1") = ComboBox1.Value
    
    'drop down list for selecting a Customer in order to filter down the list

Dim lCol As Long
    lCol = ActiveSheet.UsedRange.Columns.Count
    rCol = ActiveSheet.UsedRange.Rows.Count

For Each Cell In Range(Cells(10, 1), Cells(rCol, lCol))

Next

End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi,
try

Code:
Private Sub ComboBox1_Change()
    Range("H1") = ComboBox1.Text
    With ActiveSheet.Range("$A$9")
        .AutoFilter
    If Me.ComboBox1.ListIndex <> -1 Then
        .CurrentRegion.AutoFilter Field:=7, Criteria1:=Me.ComboBox1.Text
    End If
    End With
End Sub

place code in your worksheets code page.

Dave
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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