如何在Excel工作表的公式中大规模更改列引用?
例如,此列的公式包含G列的参考(G2,G23,G30等),我希望大量更改为H列(H2,H23,H33等)。
没有找到任何现有的相关q& a,也许没有足够的搜索,对不起并提前致谢!
答案 0 :(得分:1)
点击 A 栏并执行:
插入>柱强>
列 G 将成为 H 列,工作表中引用列 G 中的单元格的所有公式现在将引用列中的单元格的ħ强>:
在:
之后:
答案 1 :(得分:0)
快速将它们放在一起,更换功能还有很多不足之处! (非常懒,你可能需要改进它)
R
应设置为包含您要更改引用的公式的列。
真的只是一个概念证明。如果您测试它,请确保保存工作簿的副本。
Sub Main()
Dim R As Range: Set R = ThisWorkbook.Worksheets("Sheet1").Range("$E$1:$E$2")
Dim Cell As Range
Dim CellPrecedent As Range
Dim CellPrecedents As Range
Dim Retry As Boolean: Retry = False
For Each Cell In R.Cells
On Error Resume Next
Set CellPrecedents = Cell.Precedents
On Error GoTo 0
If CellPrecedents Is Nothing Then
' skip
Else
For Each CellPrecedent In CellPrecedents
If CellPrecedent.Column = 7 Then ' 7 == G
Cell.Formula = Replace(Cell.Formula, "G", "H")
GoTo Breakout
End If
Next CellPrecedent
End If
Breakout:
Next Cell
If Retry Then Main
End Sub
答案 2 :(得分:0)
谢谢大家,没关系,我已经找到了,而且很简单。我刚切换到公式视图(公式菜单),选择了给我结果的列,并用h替换(Ctrl + H)g。这一切都完成了。祝你晚安。