Find cells that contain alliteration

ollyhughes1982

Well-known Member
Joined
Nov 27, 2018
Messages
677
Office Version
  1. 365
Platform
  1. MacOS
Hi,

Re the below screenshot, would anybody please be able to advise how to find and count cells in a particular column that contain alliteration. In this example, manually counting shows that the result should be 6. Cardiff parkrun, Newport parkrun and Sharpham Fields Road parkrun do not contain alliteration, the other 6 do.

Screenshot 2021-12-06 at 17.55.19.png

I've tried a few things, but nothing is working.

Thanks in advance.

Olly.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
A way using VBA.

VBA Code:
Function ALLITERATION(r As Range)
Dim AR() As Variant:        AR = r.Value2
Dim tot As Integer:         tot = 0
Dim SP() As String
Dim tmp As String
Dim b As Boolean

For i = 1 To UBound(AR)
    SP = Split(AR(i, 1), " ")
    tmp = Left(SP(0), 1)
    b = False
    For j = 1 To UBound(SP)
        If UCase(tmp) = UCase(Left(SP(j), 1)) Then b = True
        tmp = Left(SP(j), 1)
    Next j
    If b Then tot = tot + 1
Next i

ALLITERATION = tot
End Function
 
Upvote 0
Thanks. I don't think that's an option for me in the mac version though. Looking for a way within a formula. Thanks though.
 
Upvote 0
If your only interested in the 1st two words try
Excel Formula:
=SUM(--IFERROR(LEFT(A2:A10,1)=MID(A2:A10,FIND(" ",A2:A10)+1,1),0))
 
Upvote 0
If your only interested in the 1st two words try
Excel Formula:
=SUM(--IFERROR(LEFT(A2:A10,1)=MID(A2:A10,FIND(" ",A2:A10)+1,1),0))
Thanks, that works perfectly for the first two words, so almost there. It could, however, be any two consecutive words within the name.
 
Upvote 0
Is Power Query available on Mac?

New__Document (11).xlsx
ABCD
1NameAlliteration Count:6
2Bannockburn Bush parkrun
3Batemans Bay parkrun
4Benalla Botanical Gardens parkrun
5Bendigo Botanic Gardens parkrun
6Cardiff parkrun
7Newport parkrun
8Pakapakanthi parkrun
9Parkville parkrun
10Sharpham Fiels Road parkrun
Sheet3


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Split = Table.AddColumn(Source, "Custom", each Text.Split([Name]," ")),
    Left = Table.TransformColumns(Split,{{"Custom", (lst)=> List.Transform(lst, each Text.Upper(Text.Middle(_, 0,1)))}}),
    LG = Table.AddColumn(Left, "Custom.1", (lst)=> 
        let 
            c = List.Count(lst[Custom]),
            g = Number.From(List.Contains(List.Generate(()=> 0, each _ <= c, each _ + 1, each try lst[Custom]{_} = lst[Custom]{_+1} otherwise false),true))
        in
            g
    ),
    Total = List.Sum(LG[Custom.1])
in
    Total
 
Upvote 0
Is Power Query available on Mac?

New__Document (11).xlsx
ABCD
1NameAlliteration Count:6
2Bannockburn Bush parkrun
3Batemans Bay parkrun
4Benalla Botanical Gardens parkrun
5Bendigo Botanic Gardens parkrun
6Cardiff parkrun
7Newport parkrun
8Pakapakanthi parkrun
9Parkville parkrun
10Sharpham Fiels Road parkrun
Sheet3


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Split = Table.AddColumn(Source, "Custom", each Text.Split([Name]," ")),
    Left = Table.TransformColumns(Split,{{"Custom", (lst)=> List.Transform(lst, each Text.Upper(Text.Middle(_, 0,1)))}}),
    LG = Table.AddColumn(Left, "Custom.1", (lst)=>
        let
            c = List.Count(lst[Custom]),
            g = Number.From(List.Contains(List.Generate(()=> 0, each _ <= c, each _ + 1, each try lst[Custom]{_} = lst[Custom]{_+1} otherwise false),true))
        in
            g
    ),
    Total = List.Sum(LG[Custom.1])
in
    Total
No, doesn't appear to be for my version. Thanks again for that though. Complicated / knowledgable stuff!
 
Upvote 0
I can currently think of no way to do that.
No problem Thanks for trying.

Would this also be the case for repeated words? Another one I have been trying to solve is if a word is repeated at least once in the name. Is it the same case as with letters?
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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