[英]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.