在Excel中简化Visual Basic应用程序

时间:2016-12-02 04:32:27

标签: excel vba

我必须尝试在MS Excel中使用VBA创建一个函数。 我有一个问题,我需要检查一些变量的值,并决定给输出引用变量。

示例:

 Var1 with value SB and B
 var2 with value SB and B
if Var1 = sb and var2 = sb then
 msgbox "SB for Var1 and var2"
elseif var1 =sb and var2=b then
 msgbox "SB var 1 and b var2"
elseif var1 =b and var2=sb then
 msgbox "var1 b and var2 sb"
elseif var1 =b and var2=b then
 msgbox "B for var1 and var2"
endif.

是否有任何建议我想用3个值创建6个变量,如何简化代码,所以我不需要在729行编写代码。

1 个答案:

答案 0 :(得分:0)

@John Coleman,谢谢你的建议。 @ user3598756我的gool只是根据变量的值显示输出(作为我的例子。)

我有一个想法,使用多个demention数组,但我找不到它的语法。我只看到singel line array。