我正在尝试编写代码来清除B列中带引号"作为第一个角色。非常感谢任何帮助
答案 0 :(得分:0)
考虑:
Sub KlearUp()
Dim rng As Range, r As Range, rKill As Range
Set rng = Range("B:B").Cells.SpecialCells(xlCellTypeConstants)
For Each r In rng
If Left(r.Value, 1) = Chr(34) Then
If rKill Is Nothing Then
Set rKill = r
Else
Set rKill = Union(r, rKill)
End If
End If
Next r
If rKill Is Nothing Then
Else
rKill.Clear
End If
End Sub
修改#1:强>
如果单元格包含公式而不是常量,则替换:
Set rng = Range("B:B").Cells.SpecialCells(xlCellTypeConstants)
使用:
Set rng = Range("B:B").Cells.SpecialCells(xlCellTypeFormulas)