PDA

View Full Version : Combobox on a form



ukdane
11-12-2008, 03:36 PM
Excel 2000.

I have a workbook that contains 1 worksheet ("Datalist") which has a named region "Equipment".
Worksheet 2 ("Sheet2") containes a dropdownlist (Cell O3), which lists the items in Equipment.
I have a form, which contains a combobox. When the form activates, I want it to default to show the data on sheet2 (Cell O3). BUT I want the combobox items to list the contents of "Equipment", on the Datalist sheet.
How do I set these parameters?

Cheers

Bob Phillips
11-12-2008, 04:13 PM
Without seeing anything



Private Sub Userform_Activate()

With Me.ComboBox1

.List = Application.Transpose(Worksheets("Equipment").Range("A1:A10"))
.ListIndex = Application.Match(Worksheets("Sheet2").Range("O3").Value, Worksheets("Equipment").Columns("A"), 0) - 1
End With
End Sub

ukdane
11-14-2008, 09:54 AM
The .ListIndex line isn't working. I'm getting a runtime error "9". Subscript out of range.

lucas
11-14-2008, 10:35 AM
subscript out of range usually means it can't find something. Check the spelling of the sheet names on the tabs and in the code.

post the workbook...