Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default How to prevent list item selection

I'm having one of those blond moments (no offense to any blonds). I have a
simple list box to display information. I want to immediately unselect any
item that is selected. None of the obvious items I've tried worked. Any
suggestions?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default How to prevent list item selection

Set the value to -1



"Robert Flanagan" wrote in message
...
I'm having one of those blond moments (no offense to any blonds). I have
a simple list box to display information. I want to immediately unselect
any item that is selected. None of the obvious items I've tried worked.
Any suggestions?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default How to prevent list item selection

Sorry, ListIndex = -1


"Robert Flanagan" wrote in message
...
I'm having one of those blond moments (no offense to any blonds). I have
a simple list box to display information. I want to immediately unselect
any item that is selected. None of the obvious items I've tried worked.
Any suggestions?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to prevent list item selection

You forgot to tell us where you got the ListBox from... the Control ToolBox
toolbar or the Forms toolbar. Try one of these (whichever is relevant to
your setup)...

Control ToolBox Toolbar
==========================
ToolBox: WorkSheets("Sheet1").ListBox1.ListIndex = -1

Forms Toolbar
==========================
WorkSheets("Sheet1").ActiveSheet.Shapes("List Box 2"). _
OLEFormat.Object.ListIndex = 0

Change the name of the worksheet and the name of the ListBox to match the
actual names used in your setup.

--
Rick (MVP - Excel)


"Robert Flanagan" wrote in message
...
I'm having one of those blond moments (no offense to any blonds). I have
a simple list box to display information. I want to immediately unselect
any item that is selected. None of the obvious items I've tried worked.
Any suggestions?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to prevent list item selection

I think you meant:

WorkSheets("Sheet1").Shapes("List Box 2"). _
OLEFormat.Object.ListIndex = 0

or

ActiveSheet.Shapes("List Box 2"). _
OLEFormat.Object.ListIndex = 0

=====
But another way is to go through the Listboxes collection:

Worksheets("Sheet1").ListBoxes("List box 2").ListIndex = 0



Rick Rothstein wrote:

You forgot to tell us where you got the ListBox from... the Control ToolBox
toolbar or the Forms toolbar. Try one of these (whichever is relevant to
your setup)...

Control ToolBox Toolbar
==========================
ToolBox: WorkSheets("Sheet1").ListBox1.ListIndex = -1

Forms Toolbar
==========================
WorkSheets("Sheet1").ActiveSheet.Shapes("List Box 2"). _
OLEFormat.Object.ListIndex = 0

Change the name of the worksheet and the name of the ListBox to match the
actual names used in your setup.

--
Rick (MVP - Excel)

"Robert Flanagan" wrote in message
...
I'm having one of those blond moments (no offense to any blonds). I have
a simple list box to display information. I want to immediately unselect
any item that is selected. None of the obvious items I've tried worked.
Any suggestions?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default How to prevent list item selection

Ron and JLG, the list box is on a user form. I have the list index set
initially at -1. But the list box is clickable and the user can select any
item. I can trap the mouse up event and change the list index back to -1,
but the item clicked is still blue. Repaint doesn't change the item to
unselected.

The only solution I have found is to set up a Do..Loop and hide and reshow
the form via the mouse up event and a public variable. The mouse up event
sets the variable to reshow and to hide the form. And setting the listindex
back to -1. This just doesn't seem like an elegant solution <grin.

Bob

"Robert Flanagan" wrote in message
...
I'm having one of those blond moments (no offense to any blonds). I have
a simple list box to display information. I want to immediately unselect
any item that is selected. None of the obvious items I've tried worked.
Any suggestions?



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to prevent list item selection

Thanks for catching that Dave (I had meant to post it the first way you
showed).

--
Rick (MVP - Excel)


"Dave Peterson" wrote in message
...
I think you meant:

WorkSheets("Sheet1").Shapes("List Box 2"). _
OLEFormat.Object.ListIndex = 0

or

ActiveSheet.Shapes("List Box 2"). _
OLEFormat.Object.ListIndex = 0

=====
But another way is to go through the Listboxes collection:

Worksheets("Sheet1").ListBoxes("List box 2").ListIndex = 0



Rick Rothstein wrote:

You forgot to tell us where you got the ListBox from... the Control
ToolBox
toolbar or the Forms toolbar. Try one of these (whichever is relevant to
your setup)...

Control ToolBox Toolbar
==========================
ToolBox: WorkSheets("Sheet1").ListBox1.ListIndex = -1

Forms Toolbar
==========================
WorkSheets("Sheet1").ActiveSheet.Shapes("List Box 2"). _
OLEFormat.Object.ListIndex = 0

Change the name of the worksheet and the name of the ListBox to match the
actual names used in your setup.

--
Rick (MVP - Excel)

"Robert Flanagan" wrote in message
...
I'm having one of those blond moments (no offense to any blonds). I
have
a simple list box to display information. I want to immediately
unselect
any item that is selected. None of the obvious items I've tried
worked.
Any suggestions?


--

Dave Peterson


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to prevent list item selection

Try this in the mouseup, and/or maybe in the Exit event if you want to cater
for keyboard use

With Me.ListBox1
.List = .List
End With

Curiosity, Why?

Regards,
Peter T

"Robert Flanagan" wrote in message
...
Ron and JLG, the list box is on a user form. I have the list index set
initially at -1. But the list box is clickable and the user can select
any item. I can trap the mouse up event and change the list index back
to -1, but the item clicked is still blue. Repaint doesn't change the
item to unselected.

The only solution I have found is to set up a Do..Loop and hide and reshow
the form via the mouse up event and a public variable. The mouse up event
sets the variable to reshow and to hide the form. And setting the
listindex back to -1. This just doesn't seem like an elegant solution
<grin.

Bob

"Robert Flanagan" wrote in message
...
I'm having one of those blond moments (no offense to any blonds). I have
a simple list box to display information. I want to immediately unselect
any item that is selected. None of the obvious items I've tried worked.
Any suggestions?





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default How to prevent list item selection

Peter that works by replacing the list with itself. Therefore it is the
same as doing a clear and re-entering the list. I did have to set the
listindex to -1 however. If I did not do so, the selection stayed
highlighted in blue.

One problem with that appraoch is the list scrolls back to the top. I
tested the hide and reshow approach and the list stays as scrolled. This is
of value so it looks like hide and reshow is the approach.

Bob

"Peter T" <peter_t@discussions wrote in message
...
Try this in the mouseup, and/or maybe in the Exit event if you want to
cater for keyboard use

With Me.ListBox1
.List = .List
End With

Curiosity, Why?

Regards,
Peter T

"Robert Flanagan" wrote in message
...
Ron and JLG, the list box is on a user form. I have the list index set
initially at -1. But the list box is clickable and the user can select
any item. I can trap the mouse up event and change the list index back
to -1, but the item clicked is still blue. Repaint doesn't change the
item to unselected.

The only solution I have found is to set up a Do..Loop and hide and
reshow the form via the mouse up event and a public variable. The mouse
up event sets the variable to reshow and to hide the form. And setting
the listindex back to -1. This just doesn't seem like an elegant
solution <grin.

Bob

"Robert Flanagan" wrote in message
...
I'm having one of those blond moments (no offense to any blonds). I
have a simple list box to display information. I want to immediately
unselect any item that is selected. None of the obvious items I've
tried worked. Any suggestions?







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
I need to pair each item on one list to each item on another list Peter R. Excel Worksheet Functions 1 August 24th 07 03:04 AM
Combobox item selection+pop up list N.F[_2_] Excel Programming 3 June 13th 07 10:53 PM
How to Auto-populate cell based on selection of a list item AK9955 Excel Discussion (Misc queries) 2 April 30th 07 10:04 AM
limit cell list selection based on the selection of another list lorraine Excel Worksheet Functions 2 December 14th 04 08:17 PM
Selecting an Item from a List and getting a different item to pop. Matt Excel Worksheet Functions 1 December 7th 04 02:37 PM


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

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

About Us

"It's about Microsoft Excel"