ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing a comboBox to a sub (https://www.excelbanter.com/excel-programming/359940-passing-combobox-sub.html)

cmpcwil2[_13_]

Passing a comboBox to a sub
 

I am trying to pass a comboBox to a sub to carry out sort on the items,
but I am having difficulty in doing this using the following...

Sub BubbleSortCombo(ByRef myCombo As MSForms.ComboBox)

Then call the sub()

BubbleSortCombo("ComboBox 1")
returns a type mismatch error I know it is to do with the different
type of control but can't figure it out. I am using a ComboBox from the
VB toolbox.

Can anyone help?


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=536793


Lucas Swanson

Passing a comboBox to a sub
 
I think your problem might be that when you pass "ComboBox 1" you are not
actually passing it the combo box, you are passing the string "ComboBox 1"

Try calling the sub this way:

BubbleSortCombo(ComboBox1)

(Control names, like any variable name, cannot include spaces.)

Hopefully this helps.

"cmpcwil2" wrote:


I am trying to pass a comboBox to a sub to carry out sort on the items,
but I am having difficulty in doing this using the following...

Sub BubbleSortCombo(ByRef myCombo As MSForms.ComboBox)

Then call the sub()

BubbleSortCombo("ComboBox 1")
returns a type mismatch error I know it is to do with the different
type of control but can't figure it out. I am using a ComboBox from the
VB toolbox.

Can anyone help?


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=536793



cmpcwil2[_14_]

Passing a comboBox to a sub
 

Thanks for the help it works fine now!!!:)


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=536793



All times are GMT +1. The time now is 12:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com