Calling Private Macros N number of times in Public Macros. Xl 97. (1 Viewer)

lambuhere1

Registered User.
Local time
Today, 10:34
Joined
Nov 19, 2001
Messages
28
Hi

I wanted to have some clarifications from you. How can I call Private modules in Public modules. I have many macros.

For eg. My Public macro is grouping_list() and my private macro is CommandButton1_click()

I want to call the private macro into the public macro and perform a looping action.

My code should be looking like this. I am trying to gather instrument groups. The instrument names are in the list already. The user has to inform the total groups in instrumentation and for each group, select the instruments. No instrument is used twice.

Sub Grouping_inst()' Public Macro
Dim boxes As Integer, m As Integer, i As Integer, msg As String
boxes = InputBox("How many Instrument groups are there?")
For m = 1 To boxes
MsgBox " Select the group " & m & " instruments "
'CALL COMMAND BUTTON 1 HERE
'UNLOAD LIST SELECTION HERE AFTER USER PRESSES OK FOR SELECTING THE NEXT GROUP.
Next m
End Sub


Private Sub CommandButton1_Click()
Dim i As Integer, msg As String, t As Integer, MyVals() As String
t = 1
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

End Sub


I hope that the EXCELlent peopel in here can esily figure it out.


Thanks a lot for your help.

I was thinking if we can store the selected instrument groups i an array for future reference. Like group(1, selection list), group(2, selection list), group (m, selectionlist). Is it possible/

Thanks a lot for your help.

Ram P
 

Users who are viewing this thread

Top Bottom