Conditional format match highlight in red font

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Using Excel 2010
Hello,

I need Conditional format VBA or formula highlight matches in red font.

For example I have some join pattern separated by vertical bar in range C6:C14 and results in range E1:H1 in the separate cells

I want highlight pattern value in red as result match with E1:H1 as per example show below

CF.xlsm
ABCDEFGHI
11121
2
3
4
5
62 | 1 | 1 | 1
72 | 1 | 1 | X
82 | 1 | 1 | 2
92 | 1 | X | 1
102 | 1 | X | X
112 | 1 | X | 2
122 | 1 | 2 | 1
132 | 1 | 2 | X
142 | 1 | 2 | 2
15
16
17
CF
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C6:C14Expression=SI(C6=AI$1&" | "&AJ$1&" | "&AK$1&" | "&AL$1;1;0)textNO


Regards,
Moti
 

Attachments

  • CF.png
    CF.png
    16 KB · Views: 7

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi Moti,
This might do until something more elegant comes along:
VBA Code:
Option Explicit
Sub MotRed()
    Application.ScreenUpdating = False
    Dim r As Range, c As Range
    Set r = Cells(6, 3).CurrentRegion
    r.Font.Color = vbBlack
    Dim i As Long, a, b
    a = Application.Transpose(Cells(1, 5).Resize(1, 4))
    b = Array(1, 5, 9, 13)
    For Each c In r
        For i = LBound(b) To UBound(b)
                If Mid(c, b(i), 1) = CStr(a(i + 1, 1)) Then c.Characters(b(i), 1).Font.Color = vbRed
        Next i
    Next c
    Application.ScreenUpdating = True
End Sub
 
Upvote 1
Solution
Hi Moti,
This might do until something more elegant comes along:
VBA Code:
Option Explicit
Sub MotRed()
    Application.ScreenUpdating = False
    Dim r As Range, c As Range
    Set r = Cells(6, 3).CurrentRegion
    r.Font.Color = vbBlack
    Dim i As Long, a, b
    a = Application.Transpose(Cells(1, 5).Resize(1, 4))
    b = Array(1, 5, 9, 13)
    For Each c In r
        For i = LBound(b) To UBound(b)
                If Mid(c, b(i), 1) = CStr(a(i + 1, 1)) Then c.Characters(b(i), 1).Font.Color = vbRed
        Next i
    Next c
    Application.ScreenUpdating = True
End Sub
Hello kevin9999, for me if solution works it is well-designed. I am happy it worked excellent for me. (y)

Hope you have a wonderful week ahead! Good Luck.

Kind regards,
Moti :)
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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