View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Listbox rowsource on Userform


Wendy,
Some suggestions...
Declare ws as a worksheet
Prefix "Rows.Count" with ws... ws.RowsCount
Verify that the workbook name and sheet name are correct.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Wendy"
wrote in message
Hi
I'm trying to set the rowsource of a listbox, I keep getting subscript out
of range error.
Thanks
Wendy

Private Sub UserForm_Initialize()
Dim LastRowNo As Long
Dim LastRow as String
Set ws = Workbooks("post.xls").Worksheets("data")


'find first empty row in sheet

LastRowNo = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
LastRow = "A2:C" & LastRowNo

Me.ListBox1.RowSource = LastRow

End Sub