Excel 2003 Conditional Formatting

Hello Experts; I need to apply conditional formatting with color for each cell in Sheet1 whose value is compared with same cell in Sheet2., as per attached file.
A solution is needed for Excel 2003 and earlier versions, where other conditional formatting exists leaving no room for more formulas, so clearly I am looking for a private sub solution to be operating in Sheet1.

Thank you, N2V Conditional-Formatting.xls
NewToVBAAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StephenJRCommented:
This? You can add more colours if required.
Sub x()

Dim r As Range

With Sheets("A")
    For Each r In .Range("C3:R22")
        Select Case r.Value - Sheets("B").Range(r.Address).Value
            Case 0: r.Interior.ColorIndex = 10
            Case 1: r.Interior.ColorIndex = 6
            Case 2: r.Interior.ColorIndex = 44
            Case 3: r.Interior.ColorIndex = 3
            Case Else: r.Interior.ColorIndex = 2
        End Select
    Next r
End With
    
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Patrick MatthewsCommented:
NewToVBA,

Assuming you have a range of 6 cells, named Colors, that have the background colors you want to apply for the absolute differences of 0 through 6, this code seems to work for me:

Private Sub Worksheet_Calculate()
    
    Dim rng As Range
    Dim cel As Range
    Dim OtherCel As Range
    Dim Diff As Long
    
    Set rng = Range("Grid")
    For Each cel In rng.Cells
        Set OtherCel = Me.Parent.Worksheets("B").Range(cel.Address)
        Diff = Abs(cel - OtherCel)
        cel.Interior.ColorIndex = Range("Colors").Cells(Diff + 1).Interior.ColorIndex
    Next
    
End Sub

Open in new window


Patrick
0
gtglonerCommented:
Here's a wild guess, don't know if this is what you want:
Conditional-Formatting.xls
0
NewToVBAAuthor Commented:
Both solutions are effective and provide education I was looking for. Thank you very much!

Cheers, V
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.