Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
select items in a list box with a macro?
Instead of a mouse, can you select items in a list box with a macro?
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
select items in a list box with a macro?
You can use a line like this:
Me.ListBox1.ListIndex = 0 The first item in the listbox is item 0. If you allow multiple selections, then this worked ok for me: Option Explicit Private Sub CommandButton1_Click() Dim iCtr As Long With Me.ListBox1 For iCtr = 0 To .ListCount - 1 If iCtr = 0 _ Or iCtr = 3 _ Or iCtr = 5 Then .Selected(iCtr) = True Else .Selected(iCtr) = False End If Next iCtr End With End Sub Private Sub UserForm_Initialize() Dim iCtr As Long With Me.ListBox1 .MultiSelect = fmMultiSelectMulti For iCtr = 1 To 10 .AddItem "A" & iCtr Next iCtr End With End Sub Fan924 wrote: Instead of a mouse, can you select items in a list box with a macro? -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
select items in a list box with a macro?
Me.ListBox1.ListIndex = 0
Nice. I used it to scroll through the list with a small wait in between. Can I pull focus on the listbox and use the keyboards up & down arrows. Is that programmable? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
select items in a list box with a macro?
I'm not sure what pull focus means (.setfocus???), but you can change the top
item that you see in the listbox with a line like: Me.ListBox1.TopIndex = 5 (0 is still the first item.) Fan924 wrote: Me.ListBox1.ListIndex = 0 Nice. I used it to scroll through the list with a small wait in between. Can I pull focus on the listbox and use the keyboards up & down arrows. Is that programmable? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Drop Down List - Select Multiple Items | Excel Worksheet Functions | |||
How to Pre-Select items in Multi-Select List on Form | Excel Programming | |||
Hi-lighting items in a multi-select List box | Excel Programming | |||
select multiple items from a dropdown list | Excel Worksheet Functions | |||
Create a macro to select items from an existing list .... | Excel Programming |