Hello,
I have the following code, which runs in 2 seconds, which is great. But, it highlights all the header columns even if a column does not contain any blank cells.
How do I change the code so that the header is only highlighted if a cell in a column is highlighted? Everything I've tried makes the Sub run for at least 10 seconds, which isn't ideal since this is a part of a main macro.
Goal: Highlight all blank cells in the referenced columns; if a cell in one of those columns is highlighted, highlight the corresponding column header. Example: There are blank cells highlighted in columns DF, DH, and DI, only those column headers should be highlighted.
Dim rCell As Range, rRange As Range
Dim col As Variant
Dim lastCol As Long, lastRow As Long
lastCol = last_col(ws)
lastRow = Last_Row_For_Realsies(ws, lastCol)
Set rRange = ws.Range("DF3:DS" & lastRow)
rRange.SpecialCells(xlCellTypeBlanks).Interior.Color = RGB(255, 204, 0)
Dim checkColumns As Variant
checkColumns = Array("DF", "DG", "DH", "DI", "DJ", "DK", "DL", "DM", "DN", "DO", "DP", "DQ", "DR", "DS")
For Each col In checkColumns
If rRange.SpecialCells(xlCellTypeBlanks).Interior.Color = RGB(255, 204, 0) Then
With ws.Range(col & 2)
.Interior.Color = RGB(0, 0, 0)
.Font.Color = RGB(255, 255, 255)
End With
End If
Next col
I have the following code, which runs in 2 seconds, which is great. But, it highlights all the header columns even if a column does not contain any blank cells.
How do I change the code so that the header is only highlighted if a cell in a column is highlighted? Everything I've tried makes the Sub run for at least 10 seconds, which isn't ideal since this is a part of a main macro.
Goal: Highlight all blank cells in the referenced columns; if a cell in one of those columns is highlighted, highlight the corresponding column header. Example: There are blank cells highlighted in columns DF, DH, and DI, only those column headers should be highlighted.
Dim rCell As Range, rRange As Range
Dim col As Variant
Dim lastCol As Long, lastRow As Long
lastCol = last_col(ws)
lastRow = Last_Row_For_Realsies(ws, lastCol)
Set rRange = ws.Range("DF3:DS" & lastRow)
rRange.SpecialCells(xlCellTypeBlanks).Interior.Color = RGB(255, 204, 0)
Dim checkColumns As Variant
checkColumns = Array("DF", "DG", "DH", "DI", "DJ", "DK", "DL", "DM", "DN", "DO", "DP", "DQ", "DR", "DS")
For Each col In checkColumns
If rRange.SpecialCells(xlCellTypeBlanks).Interior.Color = RGB(255, 204, 0) Then
With ws.Range(col & 2)
.Interior.Color = RGB(0, 0, 0)
.Font.Color = RGB(255, 255, 255)
End With
End If
Next col