VBA有一个子运行另一个子 [英] VBA have a sub run another sub

查看:106
本文介绍了VBA有一个子运行另一个子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何运行存储在另一个工作表模块中的sub?

how to run a sub stored in another worksheet's module?

工作表1

sub endDay()
    'something here
end sub

worksheet2

sub reCalc()
    'something here
end sub

我希望recalc能够独立运行,但 我希望能够按一下"endDay"的按钮,使其起作用,然后在最后执行重新计算",而不是按一个,然后转到sheet2来按另一个.

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?

推荐答案

看看工作表的代码名称-您可以在Visual Basic编辑器的树形视图中看到它们.通常将它们命名为Sheet1Sheet2等(独立于实际的工作表名称,在括号中显示).在您的代码中使用此名称)(而不是Worksheets("Sheet1")),您还将获得一个自动完成列表-带有您的订阅者!

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!

因此,这将完成工作:


Sheet1.reCalc

这篇关于VBA有一个子运行另一个子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆