Hello,
I have this code that extracts rows with highlighted cells based on which column I point to. Right now it points to column "C".
My data range spans from Column C through Column N.
Each time I run this code I manually change column reference. Highlighted cells can be found anywhere between Columns C:N.
Is there a way to copy all of the rows with one click without the need to manually change column reference?
This is the piece of code that I change each time:
This is the whole macro:
I have this code that extracts rows with highlighted cells based on which column I point to. Right now it points to column "C".
My data range spans from Column C through Column N.
Each time I run this code I manually change column reference. Highlighted cells can be found anywhere between Columns C:N.
Is there a way to copy all of the rows with one click without the need to manually change column reference?
This is the piece of code that I change each time:
Code:
If Sheets("1").Range("C" & i).Interior.ColorIndex <> xlNone Then
This is the whole macro:
Code:
Sub CopyHighlightedRows()
Dim LastRow As Long
Dim i As Long, j As Long
With Worksheets("1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With Worksheets("Report")
j = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
End With
For i = 2 To LastRow
With Worksheets("1")
If Sheets("1").Range("C" & i).Interior.ColorIndex <> xlNone Then
.Rows(i).Copy Destination:=Worksheets("Report").Range("A" & j)
j = j + 1
End If
End With
Next i
End Sub