Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Selected listbox item

Hi All,

I have listbox having six columns for each row.
I need to know which item is been selected ( six columns item ).

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Selected listbox item

Use List Index. You can only select one row so you can't tell which column
that is selected. This doesn't work with multi-select option. The index
number starts with zero.

" wrote:

Hi All,

I have listbox having six columns for each row.
I need to know which item is been selected ( six columns item ).


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Selected listbox item

Another way is to use the Selected property, which works for all MultiSelect
settings, whether Single, Multi or Extended.

Dim n As Long
With Me.ListBox1
For n = 0 To .ListCount - 1
If .Selected(n) = True Then
MsgBox .List(n, 0) ' First column, selected row(s)
End If
Next
End With

The List property is zero-based, so List(n,0) is the 1st column, List(n,1)
is the 2nd column. The row selection is zero-based too, so List(1,0) is the
2nd row, 1st column. Read more about this in VBA help: "List Property
(Forms)" and "Selected Property (Forms)".

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

wrote in message
...
Hi All,

I have listbox having six columns for each row.
I need to know which item is been selected ( six columns item ).



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
Selected ListBox item to TextBox Honnore Excel Programming 6 April 27th 09 06:57 AM
Worksheet Listbox selected item? Webtechie Excel Programming 3 August 14th 08 08:27 PM
Delete selected Item from listbox Office_Novice Excel Programming 2 May 1st 08 03:12 PM
How to get the index in VBA of the selected item in a ListBox Stefan Mueller[_2_] Excel Programming 4 July 16th 07 07:19 PM
How to copy selected listbox item to sheet michdan Excel Programming 1 July 14th 05 12:49 PM


All times are GMT +1. The time now is 01:11 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"