I am new to VBA and am trying to delete cells that have a certain fill color. I cannot delete the entire row with cells that have fills because that would delete data that I need. I am trying to use a loop, but it does not delete all the cells that contain the fill color I specify, only some towards the top of my spreadsheet. If I run the macro several times, it will end up deleting all the cells with the color that I specified.
Range("A1:AF150").Select
For Each cell In Selection
If cell.Interior.Color = RGB(112, 48, 160) Then
cell.Delete
End If
Next cell
Aucun commentaire:
Enregistrer un commentaire