I have been working with conditional formatting and I thought how it would look like if replaced with a "manual" comparison in VBA.
Let's say I want to compare cells between Row 1 and Row 2, meaning I compare A1 to A2, B1 to B2 etc. Whenever the value in row 2 is bigger, I want to highlight this in row 2.
If I don't want to do this with conditional formatting, how do I go about this? Do I have to loop through the cells to compare or is there a way to do it without a loop? With a loop it should look like this:
Option Explicit Sub Testing() Dim ws As Worksheet Dim i As Long Dim rng As Range Set ws = ThisWorkbook.ActiveSheet Set rng = ws.Range("A2:E2") For i = 1 To rng.Count If ws.Cells(2, i).Value > ws.Cells(1, i).Value Then ws.Cells(2, i).Interior.ColorIndex = 44 End If Next End Sub Is there a way to use less code to achieve the same result? I'm just wondering if I'm unaware of some smarter, alternative way to go about this.
rngbut then hardcodes everything. (Ok I get it, it's just an illustration.)