Pass Object from UserForm to Code Module
Hi smartin,
1. THe collection is being built in the UserForm.
2. It's being passed from the Userform to the Module. THe module starts
everything, and it calls the userform.
3. The object will be a collection of worksheet names.
Thanks for all your help.
--
Programmer on Budget
"smartin" wrote:
Budget Programmer wrote:
Hello,
At a certain point in my code module, I need my user to determine which of
the worksheets in the workbook need further processing. In order to
accomplish this I made a UserForm with a ListBox. It lists all the
worksheets in the workbook. The user pics the worksheets that need further
processing, which I store that in a Collection. That part seems works fine.
My problem is that I can't seem to pass the collection back to the module.
I can pass a variant OK, but I can't seem to pass a collection.
What's a good way to approach this?
Many Thanks.
You can pass a collection as a parameter. E.g., this works:
'Worksheet code:
Private Sub CommandButton1_Click()
Dim myCol As New Collection
myCol.Add ("a")
myCol.Add ("c")
test myCol
End Sub
'Module code:
Sub test(acol As Collection)
Dim i As Long
For i = 1 To acol.Count
Debug.Print acol.Item(i)
Next i
End Sub
The questions for you are
- where are you building the collection
- from where are you passing the collection
- what is the scope of the collection object
|