Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Any more effective method to get selected item in Listbox?

Hi,

I have a question about the Userform.listbox

I would like to make a userform, which has 2 listbox. The first one
(listbox1) is showing the sheet name in workbook. Another (listbox2)
is showing the range(cells(1,1),cells(1,1).end(xltoright).column) of
select sheet name (selected at listbox1)

my normal practice to get selected item in listbox is below. Any more
effective method?
_______________________________________
k = userform.lisbox1.ListCount
j = 1
For i = 1 To k
If userform.lisbox1.Selected(i - 1) = True Then
ReDim Preserve Array(j)
Array(j) = i
j = j + 1
End If
Next i
_______________________________________
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Any more effective method to get selected item in Listbox?


[either Value or Text will get the data. Listindex will get the item
numbver in the list with the first one = 0. Setting ListIndex to -1
will deselect all items.


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=176311

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Any more effective method to get selected item in Listbox?

Listbox1.Value

HTH

Bob

"Danny" wrote in message
...
Hi,

I have a question about the Userform.listbox

I would like to make a userform, which has 2 listbox. The first one
(listbox1) is showing the sheet name in workbook. Another (listbox2)
is showing the range(cells(1,1),cells(1,1).end(xltoright).column) of
select sheet name (selected at listbox1)

my normal practice to get selected item in listbox is below. Any more
effective method?
_______________________________________
k = userform.lisbox1.ListCount
j = 1
For i = 1 To k
If userform.lisbox1.Selected(i - 1) = True Then
ReDim Preserve Array(j)
Array(j) = i
j = j + 1
End If
Next i
_______________________________________



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Any more effective method to get selected item in Listbox?

Thank you all,

how about if the selected items is more than one? Must need the loop
to determine?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Any more effective method to get selected item in Listbox?

IF more than one, yes you have to loop and pick them out.

HTH

Bob

"Danny" wrote in message
...
Thank you all,

how about if the selected items is more than one? Must need the loop
to determine?



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 [email protected] Excel Programming 2 May 25th 09 12:15 PM
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


All times are GMT +1. The time now is 03:23 PM.

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"