so I made this code to delete all the columns that have a interior red cells in row 18. The code works.
The problem is it does not work when I conditional format the cells in that row. What I planned to do was conditional format the row then use the macro to quickly clear the columns with the red cells.
It works when I fill in a cell with red but not when I use conditional formatting. It seems like it should be the same red in conditional formatting.
Sub sbDelete_Columns_Based_On_Cell_Color()
Dim lColumn As Long
Dim iCntr As Long
lColumn = 50
For iCntr = lColumn To 1 Step -1
If Cells(18, iCntr).Interior.Color = Excel.XlRgbColor.rgbRed Then
Columns(iCntr).Delete
End If
Next iCntr
End Sub
Cells(18, iCntr).DISPLAYFORMAT.Interior.Color
– user11060139