Excel,VBA:如何将多个变量传递给.OnAction [英] Excel, VBA: How to pass multiple variables to .OnAction

查看:171
本文介绍了Excel,VBA:如何将多个变量传递给.OnAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将多个变量传递给.OnAction调用一个按钮。我找不到与多个变量相关的答案,我只能用一个变量来做。这是我为一个变量工作的:

I am trying to pass multiple variables to a .OnAction call for a button. I have not been able to find answers that relate to multiple variables, and I can do it with just one variable. Here is what I have that works for one variable:

shpBar.OnAction = "'Button_Click """ & strText & """'"

如何添加两个其他变量(如VarA和VarB) ?

How can I add two other variables to this (such as VarA and VarB)?

推荐答案

假设VarA和VarB是变体或数字变量,这将起作用:

Assuming that VarA and VarB are variants or numeric variables, this would work:

.OnAction = "'Button_Click """ & strText & """," & varA & "," & varB & " '"

如果它们是字符串,则需要在每个变量名称周围添加两个双引号。

If they are strings, you need to add two more double-quotes around each variable name.

.OnAction = "'Button_Click """ & strText & """,""" & varA & """,""" & varB & """ '"

这篇关于Excel,VBA:如何将多个变量传递给.OnAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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