How to set the selected state of an embedded ActiveX listbox

G

gromit12

Hi,

Trying to select every item in an embedded listbox. Any thoughts on
how to correct the following?

Thanks in advance.

Private Sub btnSelectAll_Click()
Dim i As Integer

With Sheets("Sheet1").OLEObjects("lstList").Object

For i = 1 To .ListCount
.Selected(i) = True
Next i

End With

End Sub
 
G

gromit12

Don't bother, I figured it out. Base 0.

With Sheets("Sheet").OLEObjects("lstList").Object

For i = 0 To .ListCount - 1
.Selected(i) = True
Next i

End With
 
Top