[英]Insert apostrophe in front of formula using vba
I am able to find the cells which contain the formulas, and even can select them. 我能够找到包含公式的单元格,甚至可以选择它们。 Now i want to insert apostrophe in front of the formulas of the selected cells. 现在,我想在所选单元格的公式前面插入撇号。
This is my code : 这是我的代码:
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
Any help. 任何帮助。
Never use Select in code 切勿在代码中使用“选择”
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.