Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Is there a way to pass a form to a function in VBA. For example, I have created several userforms all of which have a combobox that I want filled using the same set of code. Instead of including this code in each of the forms code, I want to make this a function in a module and have the form just call the function to fill the combobox. The function would accept the form name or whatever and use it to fill the combobox. I am new to VBA and have tried using Public Function FillSize(Obj As MSForms.UserForm) For i = 1 To Obj.cmdSize.ListCount 'Removes an item from the Combo Box Obj.cmdSize.RemoveItem 0 Next i With Obj.cmdSize .AddItem "AddStuff" 'Add to combo box by reading excel sheet End With End Function And I would call the function using FillSize(Me) OR FillSize(UserForm_Name) Unfortunately I am not the most experienced of programmers and I am unsure how to accomplish this, if my code is even a step in the right direction, or even if it possible to accomplish what Im asking. Thanks for any help in advance, -- Aaron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pass variable from form to form to form | Excel Programming | |||
Pass a form Listbox as an object | Excel Programming | |||
Pass string value to another form | Excel Programming | |||
Is it possible to open the VBA form with a link in a sheet and to pass variable from a cell to the VBA form? | Excel Programming | |||
Pass parameter to a form and then open it? | Excel Programming |