Hello everyone.
I'm using below code to delete the colored rows (red).
The part that I don't understand is that it always leave a few rows undeleted.
Is it because the source row changes?
If someone can help me fix it, I'd really appreciate it.
PS: the rows is colored manually.
I'm using below code to delete the colored rows (red).
The part that I don't understand is that it always leave a few rows undeleted.
Is it because the source row changes?
If someone can help me fix it, I'd really appreciate it.
PS: the rows is colored manually.
VBA Code:
Sub DeleteRedRows()
Dim sourceSheet As Worksheet
Dim sourceRow As Range
' Set the source and target sheets
Set sourceSheet = ThisWorkbook.Worksheets("NextPO") ' Replace "Sheet1" with the actual name of your source sheet
' Loop through each row in the source sheet
For Each sourceRow In sourceSheet.UsedRange.Rows
' Check if the background color of the row is red (RGB value: 65535)
If sourceRow.Interior.Color = RGB(255, 0, 0) Then sourceRow.EntireRow.Delete
Next sourceRow
MsgBox "Red rows has been deleted !"
End Sub