[英]How to clear content of rows except column A?
我有一个宏,它在我的选择(在我的宏范围(“B1:B3000”)中)删除了整行的内容,并带有淡黄色的单元格。
我的宏有效,但我不想删除 A 列的内容。
我想我应该修改这一行: rColored.EntireRow.ClearContents
Sub SelectColoredCellsVariantremovecelllightyellow()
Dim rCell As Range
Dim lColor As Long
Dim rColored As Range
Dim myselection As Range
Set myselection = Range("B1:B3000")
lColor = 10092543
Set rColored = Nothing
For Each rCell In myselection
If rCell.Interior.Color = lColor Then
If rColored Is Nothing Then
Set rColored = rCell
Else
Set rColored = Union(rColored, rCell)
End If
End If
Next
rColored.EntireRow.ClearContents
Set rCell = Nothing
Set rColored = Nothing
End Sub
这里可以使用Intersect
来限制要清除的范围:
代替
rColored.EntireRow.ClearContents
和
If Not rColored Is Nothing Then
Intersect(rColored.EntireRow, Columns("B:AB")).ClearContents
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.