2016-10-03 108 views
0

我有下面的脚本,将以下公式输入到范围A2:A100中。改进VBA代码

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

我认为这是你正在努力实现的;如果没有,请让我知道。

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