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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ListFillRange for combo box

Status
Not open for further replies.

sjh

Programmer
Oct 29, 2001
263
US
Hi,
I am using a range for a combo box values. Is it possible to add an additional entry into the combo box besides the values in the range? For example, I would like to add "All" option.

Is there an easy way to do this?

Thank you,
Susie
 
AFAIK, you can't set the source to be multiple ranges, or even a single non-contiguous range. The easiest way would just be to include that value in your source range. You could put it at the top, and hide that row. . .

VBAjedi [swords]
 
Something like this should help you out. Kinda dirty!

Code:
Dim ListRange As Range, c As Range
' change the below to match your data's range
Set ListRange = ThisWorkbook.Sheets("Sheet1").Range("A1:A10")
With ListBox1
    .RowSource = "" ' clear the RowSource, if set
    .Clear ' clear ListBox
    .AddItem "All" 'Insert "All" item
        For Each c In ListRange
            .AddItem c.Value ' Insert the values from ListRange
        Next c
    .ListIndex = 0 ' Select the first item ("All")
End With

Hope this helps!



Peace!! [americanflag] [peace] [americanflag]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top