How do I code VBA to hit button on a different worksheet?
Here's one way
ThisWorkbook.Worksheets("Sheet3").CommandButton4.V alue = True
NickHK
wrote in message
ups.com...
Yes, I am trying to fake a button click. The worksheet (there are many
worksheets, otherwise I would just click the button myself) is
protected so I can't change the code.
How do I go about doing #2? Would that fake a click?
Thanks.
NickHK wrote:
If you are trying to fake a button click, rather than Dave's suggestion
of
code location, you have a couple of options:
1 - Calling the code for the click event;
Call cmdButton_Click
But you will have change the _Click routine from Private (default) to
Public
so it can be seen outside the module.
Also reference the correct WB/WS as required.
2 - Some people feel it is wrong to call events like the above. If so
use
cmdButton.Value=True
NickHK
wrote in message
oups.com...
I have a protected worksheet that has a button that I want to execute
using VBA.
The worksheet in question is protected with the exception of certain
cells where I can paste values.
I am creating a VBA to do all the pasting but I can't figure out how
to
execute the button.
Run or Call don't work.
Help.
TIA.
|