Hi Everyone,
I am trying to improve the run-time of this particular sub. Currently, it takes 94 secs to run on a 500 row file. I realize it is not going to be a "blink and it's done" due to the fact that it's looking at several columns on a row by row basis, but I'd like to see if there's something I haven't found during my Google and YouTube search (and this site). Below is the part of the code that I need help with, please.
I'm using the column names instead of the letters/numbers because this macro is on a workbook and runs on other open workbooks where the columns are not always in the same order.
The goal is that if the columns in the "If" line of code are populated and the columns in the checkColumns are not populated, highlight the blank cells in the checkColumns. Appreciate any help given.
Next i
[/CODE]
I am trying to improve the run-time of this particular sub. Currently, it takes 94 secs to run on a 500 row file. I realize it is not going to be a "blink and it's done" due to the fact that it's looking at several columns on a row by row basis, but I'd like to see if there's something I haven't found during my Google and YouTube search (and this site). Below is the part of the code that I need help with, please.
I'm using the column names instead of the letters/numbers because this macro is on a workbook and runs on other open workbooks where the columns are not always in the same order.
The goal is that if the columns in the "If" line of code are populated and the columns in the checkColumns are not populated, highlight the blank cells in the checkColumns. Appreciate any help given.
VBA Code:
checkColumns = Array(colLtr4, colLtr5, colLtr6, colLtr7, colLtr8, colLtr9, colLtr10, colLtr11, colLtr12, colLtr13, colLtr14, colLtr15, colLtr16, colLtr17, colLtr18, colLtr19)
For i = 3 To lastRow
If ws.Range(colLtr & i) <> "" Or ws.Range(colLtr1 & i) <> "" Or ws.Range(colLtr2 & i) <> "" Or ws.Range(colLtr3 & i) <> "" Then
For Each col In checkColumns
Set rng = ws.Range(col & "3:" & col & lastRow)
Set headerCell = ws.Cells(2, col)
blank_cnt = 0
On Error Resume Next
blank_cnt = rng.SpecialCells(xlCellTypeBlanks).Count
On Error GoTo 0
If blank_cnt > 0 Then
rng.SpecialCells(xlCellTypeBlanks).Interior.Color = RGB(255, 204, 0)
headerCell.Interior.Color = RGB(0, 0, 0)
headerCell.Font.Color = RGB(255, 255, 255)
End If
Next col
End If
Next i
VBA Code:
[CODE=vba]