Excel: Counting an alphabetic range

mcwinter

New Member
Joined
Dec 25, 2011
Messages
11
Hi there
I have got a spreadsheet with a database of people and all their details, Surname (E), Name (F), Gender (L), Date of Birth (M), Age (O), etc...

So I have a demographics sheet that I calculate ages, gender etc and would like to do the following 2 tables.

1. Working out ages between 2 specified ages that I input into set cells
E.g. I want all people between the ages of 13 and 18 years old (So i put 13 into cell A13 and 18 into B13. My formula will then sit in C13 and will Also count those ages.
I want to do this so to be able to change the ages if needed

2. Working out Surnames that sit between an alphabetic range. So as I did with ages I can have "A" into A51 and "D" in B51 and it will give me all the surnames that start with those letters in a range between A and D (Including the 2 options I have in those cells)

I hope I have been clear enough. Can anyone assist? (This can be formula or VB - I am slowly learning)
Thank you!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Great thanks, didnt think of the & function for the ages. :) Now just to get the alphabetic range from surnames.
Much appreciated!
 
Last edited:
Upvote 0
2. Similarly ..

Excel Workbook
ABCDE
1
2Smith
3Jones
4Brown
5Kent
6Young
7Jones
8Lyons
9
10
11
50
51DL4
52
Count
 
Upvote 0
Thank you Peter. So this will then only count the surname if it starts with the letter in that range?
 
Upvote 0
Thank you Peter. So this will then only count the surname if it starts with the letter in that range?
Yes. Isn't that what you wanted?

My example counted Jones (twice), Kent and Lyons
 
Upvote 0
To: Peter_SSs

Sir,
I was trying this formula.

=SUM(--(CODE(LEFT(I4:I14,1))=ROW(INDIRECT("A"&CODE(J3)&":A"&CODE(K3)))))

and then Ctrl+Shift+Enter

What I intent to do was get array of first letters of surname and then match it with the letter required.

I was successful in doing this for a single letter.

=SUM(--(LEFT(A3:A585,1)="A"))

this get me the desired result.

But when I made the second part an array and tried to compare, it failed.

can you explain please?
 
Upvote 0
To: Peter_SSs

Sir,
I was trying this formula.

=SUM(--(CODE(LEFT(I4:I14,1))=ROW(INDIRECT("A"&CODE(J3)&":A"&CODE(K3)))))

and then Ctrl+Shift+Enter

What I intent to do was get array of first letters of surname and then match it with the letter required.

I was successful in doing this for a single letter.

=SUM(--(LEFT(A3:A585,1)="A"))

this get me the desired result.

But when I made the second part an array and tried to compare, it failed.

can you explain please?
I cannot explain what you are trying to do with ROW(INDIRECT etc as I have no idea. :eek:

In any case a solution with CODE() in it will error if there are any blank cells.
In any case you don't need to use code at all, you can just compare the letters. So you could have used an array formula like
{=SUM((LEFT(I4:I14,1)>=J3)*(LEFT(I4:I14,1)<=K3))}

But why not stick to a simple non-array COUNTIFS?
 
Upvote 0
Definitely, yours is a better solution. If needed i would use that only.

But I am asking a fundamental question regarding array formulas.

Let me expound.
In array formula, we generally give multiple inputs in a function which expects a single input. and Then we press ctrl+shift+enter to make excel consider it as an array function.

In my successful attempt, I generated an array with LEFT function which gave me {"A";"A";"B"} like that and i compared with a single entry "A" to get results

In my unsuccessful attempt, I wanted to generate an array with LEFT function like above and then compare it with another array {"A";"B";"C"}
As it was difficult to make the second array in form of alphabets i converted them to numbers using CODE. so i could get 2 arrays with formulas successfully.

my question is can I compare/ perform an operation with 2 arrays in a single formula with Crtl+shift +Enter method?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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