Formula to highlight a number change "from" - "to"

juliew1961

New Member
Joined
Apr 12, 2017
Messages
3
I am working on condition assessments which are conducted on a yearly basis. 1-5 with 5 meaning "needs replacement".

So I am looking for a formula so that when I enter a 5 over a 4 (say) it will highlight the cell with a style that will designate "was 4" or 5 over a 3 (say) it will highlight the cell with a style that will designate "was 3" etc etc.

Is this possible?

Would most appreciate some help - simple probably but I am a novice.

J
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi J,

The task wasn't that simple, but it is indeed possible :)

Let's assume that you have your 1-5 values stored in cells A1:A7, Sheet1. You need to open your VBA window and paste the following code into Sheet1 Worksheet (not "ThisWorkbook"):

Code:
Dim oldValue As Variant
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    oldValue = Target.Value
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = ActiveCell.Offset(-1, 0)


    If Not Application.Intersect(Range([B][COLOR=#ff8c00]"A1:A7"[/COLOR][/B]), Range(Target.Address)) Is Nothing Then
        Select Case rng.Value
        Case 5
            Select Case oldValue
                Case 1
                    rng.Interior.Color = [COLOR=#ff8c00][B]RGB(127, 187, 199)[/B][/COLOR]
                Case 2
                    rng.Interior.Color = [COLOR=#ff8c00][B]RGB(100, 135, 203)[/B][/COLOR]
                Case 3
                    rng.Interior.Color = [COLOR=#ff8c00][B]RGB(180, 53, 7)[/B][/COLOR]
                Case 4
                    rng.Interior.Color = [COLOR=#ff8c00][B]RGB(12, 250, 18)[/B][/COLOR]
            End Select
        Case Else
            Exit Sub
        End Select
    End If
End Sub

I have highlighted the most significant fields: you can change your range from A1:A7 to a range where your 1-5 values are being stored, you can also modify RGB colors for each case.

I hope it helps. Good luck.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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