paipimenta
Board Regular
- Joined
- Apr 7, 2010
- Messages
- 103
Hello Excel peeps,
I've got an ActiveX ListBox (MultiSelectExtended select mode) with a state list. User can select multiple states, which I output into a cell with:
(PS: Is there an inverse of Join( ) ? Like ArrayLoad(csv-string,array) ? )
I load lbSelectedItems like so:
Now, unfortunately I have to reload the listbox every time I open the workbook (right?). This is how I do that:
How can I take the comma-separated value from the cell and re-select the states that were selected before? Here's a beginning....
I've got an ActiveX ListBox (MultiSelectExtended select mode) with a state list. User can select multiple states, which I output into a cell with:
Code:
(In Private Sub ListBox1_Change() )
Worksheets("Master - FUW").Range("States").Value = _
Join(lbSelectedItems, ", ")
I load lbSelectedItems like so:
Code:
(Also in Private Sub ListBox1_Change() )
' Cycle through listbox and load selected items into string array
For i = 0 To ActiveSheet.ListBox1.ListCount - 1
If ActiveSheet.ListBox1.Selected(i) = True Then
intSelectedCounter = intSelectedCounter + 1
ReDim Preserve lbSelectedItems(0 To intSelectedCounter)
lbSelectedItems(intSelectedCounter) = ActiveSheet.ListBox1.List(i)
End If
Next
Now, unfortunately I have to reload the listbox every time I open the workbook (right?). This is how I do that:
Code:
Private Sub Workbook_Open()
For i = 1 To 53
Worksheets("Master - FUW").ListBox1.AddItem ActiveWorkbook.Worksheets(1).Cells(i, 7).Value
Next i
End Sub
How can I take the comma-separated value from the cell and re-select the states that were selected before? Here's a beginning....
Code:
(In Private Sub Workbook_Open() )
Dim statesCell As String
Dim allStates() As String
' Set statesCell to value of States cell
statesCell = Range("States").Value
' Reload ListBox1
For i = 1 To 53
Worksheets("Master - FUW").ListBox1.AddItem ActiveWorkbook.Worksheets(1).Cells(i, 7).Value
Next i
' Load allStates() from statesCell
' Mark members of allStates() as selected in ListBox1