改进VBA代码

我有下面的脚本,input以下公式到范围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 

我试图定义下面的variables来缩短脚本,但没有运气。

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

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

先谢谢你。

我认为这是你想要达到的目标; 如果没有,请让我知道。

 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