ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to set the selected state of an embedded ActiveX listbox (https://www.excelbanter.com/excel-discussion-misc-queries/129332-how-set-selected-state-embedded-activex-listbox.html)

[email protected]

How to set the selected state of an embedded ActiveX listbox
 
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


[email protected]

How to set the selected state of an embedded ActiveX listbox
 
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



All times are GMT +1. The time now is 11:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com