替换一些单元格引用,而不是全部

时间:2018-05-22 09:08:17

标签: excel

想要使用查找和替换单元格引用。 Ctrl-F和公式中的替换一次替换所有引用或一个单元格。我想强调几个单元格,只能替换它们。

eg..
cell B1 has formula = domestic!A5
cell B2 has formula = domestic!A6
cell B3 has formula = domestic!A7

I want it to be:
B1= domestic!A5
B2 = global!A6
B3= global!A7
Is there a way to this in excel 2013

1 个答案:

答案 0 :(得分:0)

我知道您没有请求VBA脚本,但它为您提供了一个选项,除非其他人有替代解决方案,此代码将根据需要更改任何选定单元格的公式:

  Sub ChangeFormulas()

    Dim Cel As Range
    Dim SelRng As Range

    Set SelRng = Application.Selection

    For Each Cel In SelRng.Cells

        Cel.Formula = Replace(Cel.Formula, "domestic!", "global!")

    Next Cel

  End Sub