ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reference combo box in after update sub. (https://www.excelbanter.com/excel-programming/384115-reference-combo-box-after-update-sub.html)

[email protected]

Reference combo box in after update sub.
 
I'm trying to call a function in the after update sub, and pass it the
name of the combobox, which has been updated. I'm just not sure how to
access this. Can anyone help?

Thanks


merjet

Reference combo box in after update sub.
 
ActiveControl.Name??

Hth,
Merjet



Tom Ogilvy

Reference combo box in after update sub.
 
Each afterupdate event only refers to one combobox, so

Private Sub ComboBox1_AfterUpdate()
MyMacro ComboBox1
End Sub

Sub MyMacro(CBox As MSForms.ComboBox)
MsgBox CBox.Name & " " & CBox.Value
End Sub


--
Regards,
Tom Ogilvy


" wrote:

I'm trying to call a function in the after update sub, and pass it the
name of the combobox, which has been updated. I'm just not sure how to
access this. Can anyone help?

Thanks



[email protected]

Reference combo box in after update sub.
 
On 28 Feb, 15:45, "merjet" wrote:
ActiveControl.Name??

Hth,
Merjet


Hi Merjet,

Thanks for the quick reply.
I've just tried that, but the combo box is on a multipage form, so
ActiveControl.Name just returns "multipage1".

Is there a way round this?

Laura


[email protected]

Reference combo box in after update sub.
 
Ok, between the two replies, I now have what I need.

Many thanks!

Laura



Tom Ogilvy

Reference combo box in after update sub.
 
for the edification of anyone reading this thread with a similar problem, my
original answer provided a complete solution and works fine whether with a
multipage or not and required no further modification.

Each afterupdate event only refers to one combobox, so

Private Sub ComboBox1_AfterUpdate()
MyMacro ComboBox1
End Sub

Sub MyMacro(CBox As MSForms.ComboBox)
MsgBox CBox.Name & " " & CBox.Value
End Sub

This discounts any special needs the OP may have had that were not stated in
the original question or follow on posts.

--
Regards,
Tom Ogilvy


" wrote:

Ok, between the two replies, I now have what I need.

Many thanks!

Laura





All times are GMT +1. The time now is 02:12 PM.

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