Currently I pull all my listbox data from a word document. I would like to pull it directly from a (source) excel spreadsheet as Im assuming its more efficient and would save me a couple of steps.
Im trying to modify some code that I dont know a lot about
The example below works, but Im trying to change it to work with my spreadsheet (not the sample one)
I know to change the workbook name etc, but the only part Im not sure about relates to the name mySSRange like so : Range("mySSRange").Rows.
What does "mySSRange" refer to?
Im trying to modify some code that I dont know a lot about
The example below works, but Im trying to change it to work with my spreadsheet (not the sample one)
I know to change the workbook name etc, but the only part Im not sure about relates to the name mySSRange like so : Range("mySSRange").Rows.
What does "mySSRange" refer to?
Code:
Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open("c:\temp\sourceSpreadsheet.xls")
Set xlWS = xlWB.Worksheets(1)
cRows = xlWS.Range("mySSRange").Rows.Count - xlWS.Range("mySSRange").Row + 1
ListBox1.ColumnCount = 3
With Me.ListBox1
For i = 2 To cRows
.AddItem xlWS.Range("mySSRange").Cells(i, 1)
'Use .List method to populate the remaining columns
.List(.ListCount - 1, 1) = xlWS.Range("mySSRange").Cells(i, 2)
.List(.ListCount - 1, 2) = xlWS.Range("mySSRange").Cells(i, 3)
Next i
End With
Set xlWS = Nothing
Set xlWB = Nothing
xlApp.Quit
Set xlApp = Nothing