在另一个Excel中replace文件path

我有一个Excel文件的单元格从另一台计算机上存储的文件检索数据。 我需要更新所有这些公式中的文件path,但每次更新公式时都非常繁琐,出现打开的文件窗口。 我改变这个位置也不在我的电脑上。

有没有一个快速的方法来更新文件path公式没有打开这个对话窗口?

我需要改变我的path

='\ clusfs001nas \

至:

='R:\

在“数据”选项卡下,单击“编辑链接” – 这应该显示您链接的文件,并且您可以“更改源”更新它。 或者,你可以做一个简单的查找/replace(CTRL + F,然后单击“replace”,然后键入你需要replace的path,然后在replace区域,把新的path)。

您可以使用VBA更改公式。

但是,首先,我build议你一个单元格中 ,在公式中,添加这个单元格,而不是一个真正的path。 这样,下次需要更改时,只更改一个单元格。

现在编码,改变A2和B5的例子:

Sub Change() Range("A2").Formula = type the formula here between quotes Range("B5").Formula = type the formula here between quotes end sub 

如果你在一个列中有很多单元格,你可以做一个循环:

 For i = 1 to 20 'say you have cells from row 1 to 20 Cells(i,3).Formula = type the formula here between quotes 'the number 3 above is the third column: C next