Ama*_*ath 1 excel vba excel-vba
我能够找到包含公式的单元格,甚至可以选择它们.现在我想在所选单元格的公式前面插入撇号.
这是我的代码:
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
Run Code Online (Sandbox Code Playgroud)
任何帮助.
小智 5
切勿在代码中使用Select
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
Run Code Online (Sandbox Code Playgroud)