How to call a module written in Excel on the button click of ActiveX control

1

How can I call a module written in Excel by clicking on an ActiveX control in a worksheet?

Seema

Posted 2012-05-18T12:39:52.943

Reputation: 11

Answers

2

It's not entirely clear what you're asking, but I understand this to be your problem:

You have an ActiveX Control that runs on a click event. The VBA for this is only called by the button click and cannot be called from any other Sub, but you would like to be able to call this code from another module.

I don't believe you can do that, but there is a better approach to the problem. Place the code for your ActiveX control in a new Sub in a module. Then replace the code for the button click event with the following:

Private Sub CommandButton1_Click()
Call NewSub
End Sub

Where NewSub is the name of your new Sub. This should allow you to do what you wanted.

Excellll

Posted 2012-05-18T12:39:52.943

Reputation: 11 857

0

To call subroutine located in ThisWorkbook from SHeet1: Do that: Call ThisWorkbook.ParseText

Where definition: Public Sub ParseText()

Greg

Posted 2012-05-18T12:39:52.943

Reputation: 1

0

The code for an ActiveX control, such as a button_click on a worksheet, may be called from other subs, even on other modules. Simply use the keyword "Public" to describe the ActiveX control sub instead of "Private". Then call the sub with a statement such as Call Sheets(mySheetName).myButtonName_Click.

PTL

Posted 2012-05-18T12:39:52.943

Reputation: 1