Formula for if any word in a cell starts with a specific letter?

Bakstaj

New Member
Joined
Apr 14, 2023
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Is there a formula to determine if any word in a cell begins with a specific letter? I am trying to build a workbook for people doing a reading challenge. One challenge is to read a book with a word in the title that starts with each letter of the alphabet. I want to automate it so a column for A would get an "X" if any word in the title starts with an "A" and so on through 26 columns.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Would you show a few examples and results using XL2BB please.
 
Upvote 0
You can use Asterisks in criteria based functions, like this:
=SUMIFS(D9:D13,C9:C13,"A*")
OR
=COUNTIF(C9:C13,"A*")
 
Upvote 0
The intent is that for a book of any title length, if any word in the title starts with a letter, an X will appear in that column's cell. The image shows the book "Good Omens." The intent would be for the G and O columns to populate with an "X" automatically
 

Attachments

  • book alphabet.JPG
    book alphabet.JPG
    129.4 KB · Views: 16
Upvote 0
From your clip (not XL2BB) there doesn't seem to be an "X" in either the G or O column. ???
 
Upvote 0
From your clip (not XL2BB) there doesn't seem to be an "X" in either the G or O column. ???
That's the point. I can populate them manually, but I am trying to find if there is a formula that would populate them automatically.
 
Upvote 0
What about this:

Code:
Sub markletter()
Dim str As String, i As Long
str = Cells(1, 1) & " "

While 0 <> Len(str)
For i = 65 To 90
 If Left(str, 1) = Chr(i) Then
 Cells(2, i - 64) = "X"
 GoTo NLTR
 Else
 End If
Next i
NLTR: str = Right(str, Len(str) - InStr(1, str, " "))
Wend

End Sub

Book1 (version 1).xlsb
ABCDEFGHIJKLMNOPQRSTUVWXY
1Good Omens
2XX
Sheet7
 
Upvote 0
Ok, here goes. I created a Lambda function called GetFirstLetters. It returns the first letters of each word that are separated by the Delimter provided. The formula is this:
=LAMBDA(Txt,Del,[Var],[Ltrs],[n],IF(n=0,GetFirstLetters(Txt&Del,Del,(LEN(Txt)-LEN(SUBSTITUTE(Txt,Del,""))),Var,1),IF(n<=Var,GetFirstLetters(MID(Txt,SEARCH(Del,Txt)+LEN(Del),1000),Del,Var,Ltrs&LEFT(Txt,1),n+1),Ltrs&LEFT(MID(Txt,1,SEARCH(Del,Txt)-1),1))))

You need to create a named range called GetFirstLetters and add the formula above
I then use the formula below to test if the letter is in the Lambda result.

Book2
G
15Apple Twister Junk Map
16ATJM
17K
18FALSE
Sheet1
Cell Formulas
RangeFormula
G16G16=GetFirstLetters(G15," ")
G18G18=IF(IFERROR(FIND(G17,GetFirstLetters(G15," ")),FALSE),TRUE,FALSE)
 
Upvote 0
Ok, here goes. I created a Lambda function called GetFirstLetters. It returns the first letters of each word that are separated by the Delimter provided. The formula is this:
=LAMBDA(Txt,Del,[Var],[Ltrs],[n],IF(n=0,GetFirstLetters(Txt&Del,Del,(LEN(Txt)-LEN(SUBSTITUTE(Txt,Del,""))),Var,1),IF(n<=Var,GetFirstLetters(MID(Txt,SEARCH(Del,Txt)+LEN(Del),1000),Del,Var,Ltrs&LEFT(Txt,1),n+1),Ltrs&LEFT(MID(Txt,1,SEARCH(Del,Txt)-1),1))))

You need to create a named range called GetFirstLetters and add the formula above
I then use the formula below to test if the letter is in the Lambda result.

Book2
G
15Apple Twister Junk Map
16ATJM
17K
18FALSE
Sheet1
Cell Formulas
RangeFormula
G16G16=GetFirstLetters(G15," ")
G18G18=IF(IFERROR(FIND(G17,GetFirstLetters(G15," ")),FALSE),TRUE,FALSE)
The OP runs 2016 which doesn't have LAMBDA
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,973
Members
448,933
Latest member
Bluedbw

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