改进VBA代码

时间:2016-10-03 09:42:44

标签: excel vba excel-vba

我有以下脚本,将以下公式输入A2:A100。

WBNAME3 = "=IF(AND('\\insurance\it\FileData\Computers\DIPS\Change Control\[Justice League.xlsm]iForms'!A2<>"""",    '\\insurance\it\FileData\Computers\DIPS\Change Control\[Justice League.xlsm]iForms'!E2=""""),'\\insurance\it\FileData\Computers\DIPS\Change Control\[Justice League.xlsm]iForms'!A2,"""")"
Worksheets("All Release Items").Range("E2:E100").Value = WBNAME3 

我试图定义以下变量来缩短脚本但没有运气。

Justice = "=IF(AND('\\insurance\it\FileData\Computers\DIPS\Change Control\[Justice League.xlsm]"

请有人帮忙并告诉我哪里出错了?

提前谢谢。

1 个答案:

答案 0 :(得分:1)

我认为这是你想要实现的目标;如果没有,请告诉我。

Justice = "'\\insurance\it\FileData\Computers\DIPS\Change Control\[Justice League.xlsm]iForms'"

WBNAME3 = "=IF(AND(" & Justice & "!A2<>"""",  " & Justice & "!E2=""""),!" & Justice & "!A2,"""")"
Worksheets("All Release Items").Range("E2:E100").Formula= WBNAME3