Highlight row without conditional formatting

Krispy

Board Regular
Joined
Feb 12, 2009
Messages
84
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)

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?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,661
Messages
6,120,796
Members
448,994
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top