我能够找到包含公式的单元格,甚至可以选择它们。现在我想在所选单元格的公式前插入撇号。
这是我的代码:
Sub FindFormulaCells()
Dim inputRange As Range
Set inputRange = Application.InputBox("Select a Range:", "Insert Apostrophe in front of formula", , , , , , 8)
If inputRange Is Nothing Then Exit Sub
Set inputRange = inputRange.SpecialCells(xlCellTypeFormulas, 23)
inputRange.Select
End Sub
任何帮助。
答案 0 :(得分:5)
绝不使用代码中的选择
Sub FindFormulaCells()
Dim inputRange As Range
Set inputRange = Application.InputBox("Select a Range:", "Insert Apostrophe in front of formula", , , , , , 8)
If inputRange Is Nothing Then Exit Sub
Set inputRange = inputRange.SpecialCells(xlCellTypeFormulas, 23)
dim c as range
for each c in inputRange
c.formula = "'" & c.formula
next c
End Sub