Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXCEL USING AUTOFILTER with VBA PROBLEM!!

Status
Not open for further replies.

bakoriua

Aerospace
Joined
Jun 29, 2005
Messages
3
Location
IT
HI

IT'S POSSIBLE TO COPY the FIELDS of an EXCEL AUTOFILTER (the dropdown list) in a combobox list??[ponder][neutral][neutral]


I want to choose the field to apply to a column using a combobox of a userform:



Selection.AutoFilter field:=3,Criteria1:=Me.ComboBox1.Value

There is a way to have Combox1 list the same as filter fields list?

[thumbsup2][peace]
LET ME KNOW
 
You could put everything into a collection, sort the collection and then put the items of the collection into the combobox. For example:
Code:
    Me.ComboBox1.Clear
    'fill the collection from worksheet w, cells A2, A3, ...
    i = 2
    On Error Resume Next
    Do While w.Cells(i, 1).Value <> ""
        c.Add w.Cells(i, 1).Value, CStr(w.Cells(i, 1).Value)
        i = i + 1
    Loop
    'Sort the collection, if you want.
    'Insert your favorit routine here.
    
    'Add the items of the collection into the combobox
    For Each p In c
        Me.ComboBox1.AddItem p
    Next p


Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top