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

load listbox

Status
Not open for further replies.

max1565

Technical User
Dec 16, 2002
57
US
I wrote the following code in excel 2000, win 2000 and it worked. When I try to run it in excel 2002 win xp i get the following message "select method of worksheet class failed" What do I need to change?

Private Sub UserForm_Initialize()
Sheets("work").Select

ListBox1.ColumnCount = 3
ListBox1.RowSource = "a4:D23"


End Sub

Thanks
 
Assuming that your ListBox is on a UserForm and not a WorkSheet, you don't need to select the worksheet to create a RowSource for a ListBox or a ComboBox:
Code:
Private Sub UserForm_Initialize()
with ListBox1
    .ColumnCount = 3
    .RowSource = Sheets("work").[a4:D23].address
end with
End Sub

I hope this helps!

Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top