Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings Gurus -
I have a multi-select list box, lstActivityCode. When this list box is loaded with values, I need one or more value to be hi-lighted. The same as if the user selects them. lstActivityCode.Selected(CodeNumber-1) = True Doesn't work. And I can't see any other way to do it. Anyone know how? Thanks in advance - Dan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dan,
Try something like: '============= Private Sub UserForm_Initialize() With Me.ListBox1 .RowSource = "A1: A20 " .MultiSelect = fmMultiSelectMulti .Selected(1) = True .Selected(3) = True End With End Sub '<<============= --- Regards, Norman "Dan" wrote in message ... Greetings Gurus - I have a multi-select list box, lstActivityCode. When this list box is loaded with values, I need one or more value to be hi-lighted. The same as if the user selects them. lstActivityCode.Selected(CodeNumber-1) = True Doesn't work. And I can't see any other way to do it. Anyone know how? Thanks in advance - Dan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Norman -
That's what I tried, and while it makes that particular list item "active" (that is, it fires the _Change() event), it doesn't show up as hilighted. What I am looking for is a visual indication that this partcular item (or more than one) is selected already. I tried changing the list box so that it showed check-boxes, but that also doesn't show any selection. I guess I need something that acts the same as if the user clicked on the list item(s), as that is what hilights it during run time. Dan "Norman Jones" wrote: Hi Dan, Try something like: '============= Private Sub UserForm_Initialize() With Me.ListBox1 .RowSource = "A1: A20 " .MultiSelect = fmMultiSelectMulti .Selected(1) = True .Selected(3) = True End With End Sub '<<============= --- Regards, Norman "Dan" wrote in message ... Greetings Gurus - I have a multi-select list box, lstActivityCode. When this list box is loaded with values, I need one or more value to be hi-lighted. The same as if the user selects them. lstActivityCode.Selected(CodeNumber-1) = True Doesn't work. And I can't see any other way to do it. Anyone know how? Thanks in advance - Dan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dan,
Using the suggested code - for me - the Userform is displayed and the second and fourth ListBox items are selected / highlighted - the Selected property returns a zero-based array. --- Regards, Norman "Dan" wrote in message ... Thanks Norman - That's what I tried, and while it makes that particular list item "active" (that is, it fires the _Change() event), it doesn't show up as hilighted. What I am looking for is a visual indication that this partcular item (or more than one) is selected already. I tried changing the list box so that it showed check-boxes, but that also doesn't show any selection. I guess I need something that acts the same as if the user clicked on the list item(s), as that is what hilights it during run time. Dan |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks again Norman -
I see what's going on but I don't know why. If you can, please let me know if you have any ideas for troubleshooting this? I have a loop, which is doing various things unrelated to this listbox. Inside this loop, I check some values in the spreadsheet to determine which items in the listbox need to be hilighted, and do it. So I need to be in some sort of a loop I think. If I move my code outside of this loop, and just force it to "select" items in the listbox, it works. But inside the loop it does not. In fact, if I "select" items inside my loop, it fires the listbox_Change() event. So I know it's selecting the item(s). But on the list, nothing is hilighted for some reason. Even if I just tell it to select one arbitrary item in the list, like: lstActivityCode.select(3)=TRUE it doesn't hilight it. But if I move this code just outside the loop that's running, it does work. I am trying to isolated what's going on, but if you have any troubleshooting tips, I'd love to hear them. Thanks, Dan "Norman Jones" wrote: Hi Dan, Using the suggested code - for me - the Userform is displayed and the second and fourth ListBox items are selected / highlighted - the Selected property returns a zero-based array. --- Regards, Norman "Dan" wrote in message ... Thanks Norman - That's what I tried, and while it makes that particular list item "active" (that is, it fires the _Change() event), it doesn't show up as hilighted. What I am looking for is a visual indication that this partcular item (or more than one) is selected already. I tried changing the list box so that it showed check-boxes, but that also doesn't show any selection. I guess I need something that acts the same as if the user clicked on the list item(s), as that is what hilights it during run time. Dan |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Dan,
If the suggested code works in isolation, and fails for you when incorporated into your "unrelated" loop code, it is probable that the problem resides in your loop code. As we have seen nothing of your problematic code, it is difficullt to be more helpful. --- Regards, Norman "Dan" wrote in message ... Thanks again Norman - I see what's going on but I don't know why. If you can, please let me know if you have any ideas for troubleshooting this? I have a loop, which is doing various things unrelated to this listbox. Inside this loop, I check some values in the spreadsheet to determine which items in the listbox need to be hilighted, and do it. So I need to be in some sort of a loop I think. If I move my code outside of this loop, and just force it to "select" items in the listbox, it works. But inside the loop it does not. In fact, if I "select" items inside my loop, it fires the listbox_Change() event. So I know it's selecting the item(s). But on the list, nothing is hilighted for some reason. Even if I just tell it to select one arbitrary item in the list, like: lstActivityCode.select(3)=TRUE it doesn't hilight it. But if I move this code just outside the loop that's running, it does work. I am trying to isolated what's going on, but if you have any troubleshooting tips, I'd love to hear them. Thanks, Dan "Norman Jones" wrote: Hi Dan, Using the suggested code - for me - the Userform is displayed and the second and fourth ListBox items are selected / highlighted - the Selected property returns a zero-based array. --- Regards, Norman "Dan" wrote in message ... Thanks Norman - That's what I tried, and while it makes that particular list item "active" (that is, it fires the _Change() event), it doesn't show up as hilighted. What I am looking for is a visual indication that this partcular item (or more than one) is selected already. I tried changing the list box so that it showed check-boxes, but that also doesn't show any selection. I guess I need something that acts the same as if the user clicked on the list item(s), as that is what hilights it during run time. Dan |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found it -
It turns out that the listbox was not enabled (.enabled = FALSE) before the code that "selected" the list items. After this process, I enabled the control. And the hi-lighting was not there, although the list item(s) were in fact activated. If I enable this control before making these selections, they show up fine. Thanks again for your help - sometimes all it takes is some simple code like yours that "works" to help with troubleshooting! Dan "Dan" wrote: Thanks again Norman - I see what's going on but I don't know why. If you can, please let me know if you have any ideas for troubleshooting this? I have a loop, which is doing various things unrelated to this listbox. Inside this loop, I check some values in the spreadsheet to determine which items in the listbox need to be hilighted, and do it. So I need to be in some sort of a loop I think. If I move my code outside of this loop, and just force it to "select" items in the listbox, it works. But inside the loop it does not. In fact, if I "select" items inside my loop, it fires the listbox_Change() event. So I know it's selecting the item(s). But on the list, nothing is hilighted for some reason. Even if I just tell it to select one arbitrary item in the list, like: lstActivityCode.select(3)=TRUE it doesn't hilight it. But if I move this code just outside the loop that's running, it does work. I am trying to isolated what's going on, but if you have any troubleshooting tips, I'd love to hear them. Thanks, Dan "Norman Jones" wrote: Hi Dan, Using the suggested code - for me - the Userform is displayed and the second and fourth ListBox items are selected / highlighted - the Selected property returns a zero-based array. --- Regards, Norman "Dan" wrote in message ... Thanks Norman - That's what I tried, and while it makes that particular list item "active" (that is, it fires the _Change() event), it doesn't show up as hilighted. What I am looking for is a visual indication that this partcular item (or more than one) is selected already. I tried changing the list box so that it showed check-boxes, but that also doesn't show any selection. I guess I need something that acts the same as if the user clicked on the list item(s), as that is what hilights it during run time. Dan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a way to sort a list of multi-line items? | Excel Worksheet Functions | |||
Last list item selected in a Multi-Select list box? | Excel Programming | |||
Putting items from list box multi-select onto worksheet | Excel Programming | |||
Extract values from a multi-select multi-column list-box | Excel Programming | |||
Multi Select List Box | Excel Programming |