View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Initializing User Forms

You don't need to go through two arrays to do this:

Private Sub fmPickStore_Initialize()
cbStoreList.ColumnCount = 2
cbStoreList.List = _
ThisWorkbook.Worksheets("Chart Data").Range("b3:c22").Value
End Sub

If you only want to load 1 column

Private Sub fmPickStore_Initialize()
cbStoreList.List = _
ThisWorkbook.Worksheets("Chart Data").Range("B3:B22").Value
End Sub

--
Regards,
Tom Ogilvy


"Marcotte A" wrote in message
...
I am having trouble initializing my user forms. I have a drop down list

that I want populated from a range on my spreadsheet. When that spreadsheet
is not active, the combobox doesn't get initialized. This is the initialize
code. I thought the 'ThisWorkbook' part would take care of it, but it
doesn't seem to. What am I doing wrong?

Private Sub fmPickStore_Initialize()
Dim varStoreList As Variant
Dim arrStoreList(20, 2) As Variant
Dim i As Integer
varStoreList = ThisWorkbook.Worksheets("Chart Data").Range("b3:c22")
For i = 1 To 20
arrStoreList(i, 1) = varStoreList(i)
Next i
cbStoreList.List = arrStoreList
End Sub