List Box selection Multiple in Loop. XL97 SR2

lambuhere1

Registered User.
Local time
Today, 21:41
Joined
Nov 19, 2001
Messages
28
Hi Xlers

I am trying to group isntrument data. I was able to do some coding with your help. But I am stuck up in reselcting the group. I have a list of instrments. I ask the user that How many instrument groupings are there. I use the user input to loop throught the selection process. I have the code for that as below

Sub Grouping_inst()

Dim boxes As Integer, m As Integer, i As Integer, msg As String, MyVals() As String
boxes = InputBox("How many Instrument groups are there?")
For m = 1 To boxes
MsgBox " Select the group " & m & " instruments "
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
msg = msg & vbCrLf & ListBox1.List(i)
ReDim Preserve MyVals(t)
MyVals(t) = ListBox1.List(i)
t = t + 1
End If
Next i

MsgBox " You have selected " & msg & vbCrLf & " for Group " & m

msg = ""

Next m

' Do I have to unload the list Box in Each Selection.
End Sub


Herein I am not able to select the from the list of instruments after I go into the loop. Only the selection that had been made B4 going into the loop are displayed and stored. How can I make the event hang on for each selection to be completed. Multi selection of instruments is allowed. The logis for what I am trying to do is as follows.

Ask the user how many groups of instruments are there on a component . (This is the variable in Boxes, in code above)

For this many number of groups, perform the selection individually for each group. Multi selection of instruments is allowed. (This I was trying with the For loop, above)

I want the selection after I come into the FOr loop above. Can you tell me where I am doing wrong.

My inst list is as under

inst1
inst2
inst3
inst4
inst5
......

It is stored in a namelist and used in List Box1.
And, If possible, Can we store the grouped data in a array for each group for further use? like Group(1, selected instruments), group(2, selected inst), etc....

Thanks a lot for your reply.

Ram P
 

Users who are viewing this thread

Back
Top Bottom