Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88054

How to clear content of rows except column A?

$
0
0

I have a macro which removes the content of the entire row with cells in light yellow in my selection (in my macro Range("B1:B3000")).

enter image description here

My macro works but I would like to not remove the content of column A.

I guess I should modify the line: 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

Viewing all articles
Browse latest Browse all 88054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>