how to run a sub
stored in another worksheet's module?
worksheet1
sub endDay()
'something here
end sub
worksheet2
sub reCalc()
'something here
end sub
I want recalc
to be able to run on its own but
I want to be able to press the button for "endDay", have it do its thing, and then preform "recalc" at the end instead of pressing one and then go to sheet2 to press the other.
Can someone give me a sample so I can have an idea where to begin?
Take a look at the code names for the worksheets - you can see them in the tree view in the Visual Basic Editor. Usually they are named Sheet1
, Sheet2
, etc. (independent of the actual worksheet names, which are shown in brackets). Use this name in your code )instead of Worksheets("Sheet1")
and you'll also get an autocomplete list - with your sub!
Thus, this will do the job:
Sheet1.reCalc
sheets("worksheet2").reCalc
might be what you are after
I know it is 2 years later, but today I was looking for the same thing. As far as the subs in the worksheets may be private, this is a good solution:
Sub Maina()
Run "tbl_Input.btn_main_Click"
End Sub
tbl_Input
is the VBA name of the worksheet, not the caption.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With