使用按钮编号的变量调用按钮单击模块

问题描述 投票:-1回答:1

我正在使用具有近200个按钮的Excel VBA宏。我想在一个模块中使用click事件。

我已经看到我必须将事件更改为Public并使用:

调用userform1.commandbutton1_Click或userform1.commandbutton1_Click

我想用变量更改按钮的数量以使用循环,但我不知道该怎么做。

我能够做到这一点,我想改变按钮属性:

userform1.Controls(“commandbutton”&i).caption =“test”但它不适用于“_Click”

任何帮助是极大的赞赏

excel vba forms excel-vba
1个回答
0
投票

使用Value控件的Button属性:

Me.Controls("CommandButton" & i).Value = True
© www.soinside.com 2019 - 2024. All rights reserved.