Objective: To highlight row yellow if last cell (containing formula) < 0
I would prefer an alternative to conditional formatting as this superceeds any formatting currently in place.
I have tried to achive this with the following code but it only highlights the row containing formulas. My idea was if cell.offset(0, Column containing formula - Column containing cell to be formatted)
Please advise if this possible?
I would prefer an alternative to conditional formatting as this superceeds any formatting currently in place.
I have tried to achive this with the following code but it only highlights the row containing formulas. My idea was if cell.offset(0, Column containing formula - Column containing cell to be formatted)
Code:
Sub Format_FormulaRow(ReportName As String)
Dim RowCount As Long
Dim ColCount As Long
Dim ResultsRng As Range
Dim ReportRng As Range
Dim FormulaCol As Range
Application.ScreenUpdating = False
Set ResultsRng = Range(ReportName & "_ResRng") ' range of headers for Results table
RowCount = ResultsRng.CurrentRegion.Rows.Count - 1 ' Number of rows of continuous data
ColCount = ResultsRng.CurrentRegion.Columns.Count - 1 ' Number of columns in results table
Set ReportRng = Range(Cells(ResultsRng.Row, ResultsRng.Column + ColCount), _
Cells(ResultsRng.Row + RowCount, ResultsRng.Column + ColCount))
Set FormulaCol = Cells(ResultsRng.Row, ResultsRng.Column + ColCount)
For Each cell In ReportRng
If cell.Offset(0, FormulaCol.Column - cell.Column) < 0 Then
cell.Interior.ColorIndex = 6
End If
Next
End Sub
Please advise if this possible?