combox value change selection

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,134
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have a userform and a combox in the userform. the combox ragne is autofilled from sheet 1 range c3 till the last record.
I am not sure,

If the user selects any record from me.combox then the code should do autofilter from c3:aa500, (c3 to aa3 are header) and then should stop at the visible row and then should select aa column visible record.

I have do lot of google and tried a lot but no luck.

Any idea of help.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
try this


put VBA in userform's module
Code:
Private Sub [COLOR=#000080]ComboBox1[/COLOR]_Change()
    Call GoToCellAfterFilter([COLOR=#000080]ComboBox1[/COLOR].Value)
    Unload Me
End Sub

Private Sub GoToCellAfterFilter(myCriteria As String)
    Dim rng As Range
    With Sheets("[COLOR=#ff0000]Data[/COLOR]")
        .Activate
        Set rng = .Range("C3:AA500")
        On Error Resume Next
        .ShowAllData
        .rng(1).AutoFilter
        rng.AutoFilter Field:=[COLOR=#ff0000]1[/COLOR], Criteria1:=myCriteria
        .Range(Split(Split(rng.SpecialCells(xlCellTypeVisible).Address, ",")(1), ":")(1)).Select
    End With
End Sub

notes
Amend sheet & ComboBox names
The filter matches a string
The macro filters on column C which is column 1 in your range(C:AA) - amend if necessary
 
Last edited:
Upvote 0
perfect all working good.
but the only problem is the combox list is not populating all the records. I mean,

a) if the user selects "x" the code works all good, but the userform combox then only shows "x" and lot rest of the details
b) it should only select the visible cell column AA only. currently it selects cell "AA3" if the user. if visible cell is row num 8 then the code should select aa8, if the row is 11 visible then the aa11 should be selected.
 
Upvote 0
I do not understand what you are asking :confused::confused:
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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