Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MultiSelect & order of choose

Hello! Excel 2003, form and ListBox (MultiSelect and frmListStyleOption).
User choose some positions from the ListBox and I must to know how was order
of this choose? I want this information to order results in the sheet. For
example: I can choose position 2,3,4 of the listbox, but ones in order: 234,
next 432, 342... Is it possible get this information of choose order in
VBA? Help me please! Greetings!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default MultiSelect & order of choose

Hi

Look at this example.

Create a userform with a listbox and a CommandButton, and paste this
code. Remember that the first item in the listbox is item number 0.

Option Base 1
Dim SelOrder()
Dim Counter


Private Sub CommandButton1_Click()
For n = 1 To UBound(SelOrder)
mStr = mStr & SelOrder(n)
Next
MsgBox (mStr)
End Sub

Private Sub ListBox1_Mouseup(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
Counter = Counter + 1

ReDim Preserve SelOrder(Counter)
SelOrder(Counter) = Me.ListBox1.ListIndex
End Sub


Private Sub UserForm_Initialize()
For c = 1 To 10
Me.ListBox1.AddItem "Item " & c
Next
End Sub

Hopes this helps

---
Per

On 7 Feb., 10:02, "Adax" wrote:
Hello! Excel 2003, form and ListBox (MultiSelect and frmListStyleOption).
User choose some positions from the ListBox and I must to know how was order
of this choose? I want this information to order results in the sheet. For
example: I can choose position 2,3,4 of the listbox, but ones in order: 234,
next 432, 342... *Is it possible *get this information of choose order in
VBA? Help me please! Greetings!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default MultiSelect & order of choose

You could possibly handle it with code similar to this. However, you should
realize that the user could remove a selection after previously selecting it
and therefore that needs to be handled as per the comment.

Private Sub ListBox1_Change()

If ListBox1.Selected(ListBox1.ListIndex) Then
MsgBox "Value selected = " & _
ListBox1.List(ListBox1.ListIndex)
'Code here in lieu of msgbox to save the value _
to a list on worksheet
Else
MsgBox "Value cleared = " & _
ListBox1.List(ListBox1.ListIndex)
'Code here in lieu of msgbox to remove value _
from saved list on worksheet
End If

End Sub

--
Regards,

OssieMac


"Adax" wrote:

Hello! Excel 2003, form and ListBox (MultiSelect and frmListStyleOption).
User choose some positions from the ListBox and I must to know how was order
of this choose? I want this information to order results in the sheet. For
example: I can choose position 2,3,4 of the listbox, but ones in order: 234,
next 432, 342... Is it possible get this information of choose order in
VBA? Help me please! Greetings!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default MultiSelect & order of choose

As a user, I would find this irritating -- especially if I make mistakes and
click on the wrong item in the wrong order.

Have you thought about having a "move up" and "move down" button near the
listbox.

Or even using two listboxes and moving them in the order the user wants. (Move
right, move left, ...)



Adax wrote:

Hello! Excel 2003, form and ListBox (MultiSelect and frmListStyleOption).
User choose some positions from the ListBox and I must to know how was order
of this choose? I want this information to order results in the sheet. For
example: I can choose position 2,3,4 of the listbox, but ones in order: 234,
next 432, 342... Is it possible get this information of choose order in
VBA? Help me please! Greetings!


--

Dave Peterson
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
MultiSelect Textbox Mike Excel Programming 11 January 4th 09 07:50 PM
in Me.lbx.MultiSelect = fmMultiSelectMulti x taol Excel Programming 5 March 25th 08 07:04 PM
Multiselect Listbox use RKS Excel Discussion (Misc queries) 1 May 12th 06 03:04 PM
MultiSelect Popup !<nuc!<|3h3@d Excel Programming 1 January 6th 06 06:43 PM
MultiSelect ListBox StephanieH Excel Programming 5 November 20th 04 12:29 AM


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