MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Passing Combobox as a parameter to a function


Posted by Abdul on December 23, 2001 7:52 PM

I need to pass a combobox object(on my worksheet) as a parameter to a function. I have so far failed to come up with a solution.

The function receiving the combobox would be something like:

Function Test(CB as object)
CB.Value="Hello"
End function

I would appreciate any hellp I can receive on this.


Posted by Ivan F Moala on December 23, 2001 8:39 PM

Try something like;

Function test(CB As ComboBox)
CB.Value = "Hello"
End Function


Sub AddValueCB()
test Sheet1.ComboBox1
End Sub

Posted by Abdul on December 24, 2001 4:24 AM

Unfortubnately, that does not work.
When I call the function TEST:

test Sheet1.Combobox1

I get the error "Object Required".

Posted by Ivan F Moala on December 24, 2001 4:44 AM

Abdul

How did you call the function ?? in a Sub routine?
It worked for me calling from the routine
AddValueCB below ??


Ivan Unfortubnately, that does not work.