how can i click a button on one of my sheets from the ThisWorkbook module?
i have tried the following:
nothing seems to work.Please Login or Register to view this content.
what am i doing wrong?
how can i click a button on one of my sheets from the ThisWorkbook module?
i have tried the following:
nothing seems to work.Please Login or Register to view this content.
what am i doing wrong?
If you are talking about an ActiveX command button, in the sheet module, declare the CommandButton1_Click as a Public sub.
In the ThisWorkbook module use code likePlease Login or Register to view this content.
Please Login or Register to view this content.
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
I would suggest that if you need to do this, the code should be in a normal module and visible to both the sheet's button and the ThisWorkbook code. If you do wish to do it using Run the syntax is
assuming that sheet1 is the code name of the relevant sheet.Please Login or Register to view this content.
Don
Please remember to mark your thread 'Solved' when appropriate.
I would have thought that if the sub "Commandbutton_click" is a public sub in a normal module, you can call it from any worksheet or other module by just Commandbutton_click and not have to do the Application.run with the sheet1 qualifier.
Correct- my comment about Run was assuming the current code position.
The CommandButton1_Click event code has to be in the sheet's code module for the button to trigger it, you could do
Please Login or Register to view this content.
Please Login or Register to view this content.
Please Login or Register to view this content.
@Mik
Your second solution works everytime. the first one worked one time, then failed on subsequent opens.
Can't you just put the CommandButton1_Click () sub in a general module and assign that macro to the button?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks