Help finding first letter of data

Dan Wilson

Well-known Member
Joined
Feb 5, 2006
Messages
536
Office Version
  1. 365
Platform
  1. Windows
Good day. I am running Excel out of Office365 (updated) on Windows 10 Home (updated). I have a workbook containing 3 worksheets. One worksheet is titled "50-69" and contains 3000 rows with data of songs. Another worksheet titled "Counts" contains formulas indicating totals based on various items of data from "50-69". Column A of "50-69" contains the title of each song. I have tried several different functions trying to identify how many songs start with each letter of the alphabet and a few special characters such as Parenthesis and Double-Quote. All I need is one formula to identify the count of songs starting with character "A" and I can then extrapolate the formula to find the rest. I went through the Help feature but found no answer.
Thank you for any help.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
This will only work because you have Office365, but I would use something like this:
Excel Formula:
=SUM(COUNTIF('50-69'!A:A,{"=A*","=B*"}))

Note the curly brackets around the search criteria in the COUNTIF that create an array of multiple searches. The SUM function adds the totals together, in this case everything in Column A starting with A or B. You might need to use FIND rather than just a simple "=B" for the special characters depending what characters they are.
 
Upvote 0
Solution
Another option.
Book1
ABCDE
1Song AHY
2A Hard Day's Night211
3Hey Jude
4Another Brick in the Wall
5Yesterday
Sheet4
Cell Formulas
RangeFormula
C2:E2C2=COUNTA(FILTER($A$2:$A$5,LEFT($A$2:$A$5)=C$1,0))
 
Upvote 0
.. another possibility

Dan Wilson.xlsm
A
1Song
2A Hard Day's Night
3(I Can’t Get No) Satisfaction
4You Belong To Me
510 Commandments
6Hey Jude
71000 Nights
8Another Brick in the Wall
9Yesterday
10Yeah!
11
50-69


Dan Wilson.xlsm
AB
1(1
212
3A2
4H1
5Y3
6
Counts
Cell Formulas
RangeFormula
A1:B5A1=LET(r,'50-69'!A2:A4000,u,UNIQUE(SORT(LEFT(r,1)))&"",FL,FILTER(u,u<>""),HSTACK(FL,COUNTIF(r,FL&"*")))
Dynamic array formulas.
 
Upvote 0
Using Peter's example, here is an alternative means with Power Query
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Position" = Table.SplitColumn(Source, "Song ", Splitter.SplitTextByPositions({0, 1}, false), {"Song .1", "Song .2"}),
    #"Grouped Rows" = Table.Group(#"Split Column by Position", {"Song .1"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

Book6
ABCD
1Song Song .1Count
2A Hard Day's NightA2
3(I Can’t Get No) Satisfaction(1
4You Belong To MeY3
510 Commandments12
6Hey JudeH1
71000 Nights
8Another Brick in the Wall
9Yesterday
10Yeah!
Sheet1
 
Upvote 0
This will only work because you have Office365, but I would use something like this:
Excel Formula:
=SUM(COUNTIF('50-69'!A:A,{"=A*","=B*"}))

Note the curly brackets around the search criteria in the COUNTIF that create an array of multiple searches. The SUM function adds the totals together, in this case everything in Column A starting with A or B. You might need to use FIND rather than just a simple "=B" for the special characters depending what characters they are.
Good Day tdcockers and Thank You for responding. Your formula worked very well. I never would have thought of including COUNTIF within a SUM function. I narrowed the search to each character of the alphabet, a parenthesis and numbers 1-9. I also appreciate knowing that I can select more than one character to search for. Well done. I can always count on learning something new from this forum.
 
Upvote 0
Another option.
Book1
ABCDE
1Song AHY
2A Hard Day's Night211
3Hey Jude
4Another Brick in the Wall
5Yesterday
Sheet4
Cell Formulas
RangeFormula
C2:E2C2=COUNTA(FILTER($A$2:$A$5,LEFT($A$2:$A$5)=C$1,0))
Good day AhoyNC and thank you for responding. For now, I will use the formula submitted by tdcockers, but I will experiment with your suggestion. It never hurts to learn something new.
 
Upvote 0
.. another possibility

Dan Wilson.xlsm
A
1Song
2A Hard Day's Night
3(I Can’t Get No) Satisfaction
4You Belong To Me
510 Commandments
6Hey Jude
71000 Nights
8Another Brick in the Wall
9Yesterday
10Yeah!
11
50-69


Dan Wilson.xlsm
AB
1(1
212
3A2
4H1
5Y3
6
Counts
Cell Formulas
RangeFormula
A1:B5A1=LET(r,'50-69'!A2:A4000,u,UNIQUE(SORT(LEFT(r,1)))&"",FL,FILTER(u,u<>""),HSTACK(FL,COUNTIF(r,FL&"*")))
Dynamic array formulas.
Good day Peter_SSs and thank you for responding. For now I will go with the formula submitted by tdcockers. I will experiment with your suggestion. It looks very interesting as well as complicated. I do fairly well with Macros, but I have a lot to learn about formulas.
 
Upvote 0
Using Peter's example, here is an alternative means with Power Query
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Position" = Table.SplitColumn(Source, "Song ", Splitter.SplitTextByPositions({0, 1}, false), {"Song .1", "Song .2"}),
    #"Grouped Rows" = Table.Group(#"Split Column by Position", {"Song .1"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

Book6
ABCD
1Song Song .1Count
2A Hard Day's NightA2
3(I Can’t Get No) Satisfaction(1
4You Belong To MeY3
510 Commandments12
6Hey JudeH1
71000 Nights
8Another Brick in the Wall
9Yesterday
10Yeah!
Sheet1
Good day alansidman thank you for responding. Your suggestion goes way beyond my expertise with Excel, but I will play with it and try to figure it out. I have never even heard of Power Query. It will be a good exercise.
 
Upvote 0
just another option to try

Countifs.xlsm
ABCDE
1(1
210
3a2
4h1
5y3
1d
Cell Formulas
RangeFormula
E1:E5E1=SUMPRODUCT(--(LEFT('50-69'!$A$2:$A$4000)=A1))
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
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