Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'd like to get the index of the selected item in a ListBox in VBA.
In real VB I do it with the following code: Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Sub UserForm_Initialize() Dim Counter As Long ListBox1.Clear For Counter = 1 To 20 ListBox1.AddItem "MyItem " & Counter Next CommandButton1.Caption = "Index of selected Item" End Sub Private Sub CommandButton1_Click() MsgBox (SendMessage(ListBox1.hWnd, &H19F, 0, 0)) End Sub But how can I do it in VBA (e.g. Excel)? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need selected item from listbox after double click | Excel Programming | |||
Add item to listbox, but only if it is not already there. | Excel Programming | |||
How to copy selected listbox item to sheet | Excel Programming | |||
Listbox - write newly selected item back to the worksheet | Excel Programming | |||
Count number of selected item in Listbox | Excel Programming |