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

Pre-select items in a list box through VBA

Status
Not open for further replies.

hrm1220

Technical User
Aug 31, 2005
134
US
I'm trying to preselect (or make the checkbox=true) in a combolist in Excel 2003 through VBA. This is due to the fact that 204 items are the normal selected items. I wanted to provide the flexibility to the user to either select or remove additional items.


Here's the code I have so far and the line with "lstStep_List.List(i) = True" is where it breaks
Code:
Private Sub PopulateListbox()
Cells.Select
Selection.EntireColumn.Hidden = False
Range("A1").Select
Selection.End(xlToRight).Select
endcol = ActiveCell.Column
Range("A1").Select
startrow = ActiveCell.Address
NumSteps = 0
Do While ActiveCell.Value <> ""
NumSteps = NumSteps + 1
ActiveCell.Offset(0, 1).Select
Loop
Range(startrow).Select
i = ActiveCell.Column
c = i
Do While i < NumSteps + c
If i < NumSteps + c Then
    lstStep_List.AddItem (Cells(ActiveCell.Row, i).Value)
    
    If Application.VLookup(Cells(ActiveCell.Row, i).Value, Schedule_Views.Range("a1:b260"), 2, False) = "Hide Column" Then
   [b][i] lstStep_List.List(i) = True[/i][/b] "THIS IS WHERE IT BREAKS"
    
    End If
    i = i + 1
 End If
Loop
End Sub

thx for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top