Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Hi-lighting items in a multi-select List box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Hi-lighting items in a multi-select List box

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   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Hi-lighting items in a multi-select List box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Hi-lighting items in a multi-select List box

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   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Hi-lighting items in a multi-select List box

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Hi-lighting items in a multi-select List box

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   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Hi-lighting items in a multi-select List box

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to sort a list of multi-line items? R Scott Lowden Excel Worksheet Functions 3 July 10th 07 04:54 AM
Last list item selected in a Multi-Select list box? Brian Excel Programming 3 December 5th 05 09:12 PM
Putting items from list box multi-select onto worksheet ericd Excel Programming 0 February 26th 04 08:16 PM
Extract values from a multi-select multi-column list-box Peter[_20_] Excel Programming 5 September 28th 03 04:04 PM
Multi Select List Box jacqui Excel Programming 0 July 22nd 03 12:12 PM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"