Attribute VB_Name = "HighlightRow" Option Explicit function resetColor(cell as variant) cell.Interior.Color = rgb(255,255,255) resetColor = true end function function setColor(cell as variant) cell.Interior.Color = rgb(255, 234, 167) setColor = true end function Function run(row As Integer) On Error GoTo eh Dim need_highlight as boolean Dim rsi_10_14_diff_positive as boolean Dim macd_12_25_positive as boolean need_highlight = false 'need to highlight ? rsi_10_14_diff_positive = Worksheets(TARGET_SHEET).Range(COL_RSI10_DIFF_RSI14 & CStr(row)) > 0 macd_12_25_positive = Worksheets(TARGET_SHEET).Range(COL_MACD_12_25_DAYS & CStr(row)) > 0 need_highlight = rsi_10_14_diff_positive and macd_12_25_positive if (need_highlight = True) then HighlightRow.setColor Worksheets(TARGET_SHEET).Range(COL_STOCK_CODE & CStr(row) & ":" & COL_MACD_12_25_DAYS & CStr(row)) else HighlightRow.resetColor Worksheets(TARGET_SHEET).Range(COL_STOCK_CODE & CStr(row) & ":" & COL_MACD_12_25_DAYS & CStr(row)) end if Done: Exit Function eh: Debug.Print "HighlightRow" Debug.Print row End Function