How do you alternate text colour by each person name

Fanta0575

New Member
Joined
Nov 19, 2019
Messages
21
Hi I want to be able to apply a custom format to be able to do this
Jane Seymour Stephen king Dean koontz Ian rankin

Basically alternate colour of each set of forename and surname
Is this possible?
 

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.
can you have a helper column to put a 1 or 0 in and then use that for conditional formatting ?

you can use
=IF(A2=A1,E1,1-E1) - where A is the name and E is where the helper column is
then use that column to apply conditional formatting for the row

Highlight Catergories with alternate colours.xlsx
ABCDE
2Name11
3Name11
4name20
5Name20
6name20
7name20
8name20
9Name31
10Name40
11Name51
12Name51
13name51
14Name60
15Name71
16Name80
17Name91
Sheet3
Cell Formulas
RangeFormula
E2:E17E2=IF(A2=A1,E1,1-E1)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:E17Expression=$E2=0textNO
A2:E17Expression=$E2=1textNO
 
Upvote 0
can you have a helper column to put a 1 or 0 in and then use that for conditional formatting ?

you can use
=IF(A2=A1,E1,1-E1) - where A is the name and E is where the helper column is
then use that column to apply conditional formatting for the row

Highlight Catergories with alternate colours.xlsx
ABCDE
2Name11
3Name11
4name20
5Name20
6name20
7name20
8name20
9Name31
10Name40
11Name51
12Name51
13name51
14Name60
15Name71
16Name80
17Name91
Sheet3
Cell Formulas
RangeFormula
E2:E17E2=IF(A2=A1,E1,1-E1)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:E17Expression=$E2=0textNO
A2:E17Expression=$E2=1textNO
No all names need to be in same cell
 
Upvote 0

Attachments

  • Screenshot_20220124-155512_Gallery.jpg
    Screenshot_20220124-155512_Gallery.jpg
    194 KB · Views: 11
Upvote 0
Oh, OK , sorry , you will need VBA to that , not my area for providing answers here, to out of date
 
Upvote 0
Assuming your names start in B3 and continue down, try this:

VBA Code:
Sub HiliteAlternateNames()
Dim r As Long, s As String, Loc As Long, LocA As Long, MyLen As Long

    For r = 3 To Range("B3").End(xlDown).Row
        s = Cells(r, "B").Value
        s = Replace(s, Chr(10), " ")
        s = WorksheetFunction.Trim(s)
        Cells(r, "B") = s
        s = s & " "
        Loc = 1
        While Loc > 0
            Loc = InStr(Loc + 1, s, " ")
            If Loc > 0 Then Loc = InStr(Loc + 1, s, " ")
            If Loc > 0 Then
                LocA = Loc + 1
                Loc = InStr(Loc + 1, s, " ")
                If Loc > 0 Then Loc = InStr(Loc + 1, s, " ")
            End If
            MyLen = Loc - LocA
            If MyLen < 0 Then MyLen = 100
            Cells(r, "B").Characters(Start:=LocA, Length:=MyLen).Font.Color = vbRed
        Wend
    Next r
            
End Sub

Be aware that initials, titles, 2 part surnames or first names will throw a monkey wrench in this. Perhaps use a dash in such cases.
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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