![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 31
|
Hi
My database consist of A B C Male 65 M65-M45-M22 I would like a formula to calculate the number of M's that occured that is to say that I have 3 M's in the column C, i.e to count M65 and then M45 and then M22 and to say I got 3 Thanks in advance |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Posts: 175
|
A crude way would be to do Data...Text to Columns on column C, using M as a delimiter. You can then count the columns using a Count function.
__________________
Regards, Mike. |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
By formula you could use
=LEN(C1)-LEN(SUBSTITUTE(UPPER(C1),"M","")) to see how many M's are in C1. good luck. |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Sheffield, UK
Posts: 249
|
There is a REALLY simple way, depending on what format your data will be in. If you know that the only letter will be M, and the numbers will always be 2 characters, and they will always be separated by a single hyphen, hten you can just use the length of the string:
=(LEN(C2)+1)/4 ...But I suspect what you want needs to be more versatile! |
|
|
|
|
|
#5 | |
|
New Member
Join Date: May 2002
Posts: 31
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Sheffield, UK
Posts: 249
|
Wow, IML just seen your reply. Very clever! Wish I had thought of that
|
|
|
|
|
|
#7 | |
|
New Member
Join Date: May 2002
Posts: 31
|
Quote:
How can I reneralise the formula to work for more than one row, i.e A B C Male 65 M65-M45-M23 Male 45 M65-M21 How can I calculate the number of M's in the whole column of C, i.e the answer should be 5, Can u help me. Thanks in advance |
|
|
|
|
|
|
#8 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
|
||
|
|
|
|
|
#9 | |||
|
New Member
Join Date: May 2002
Posts: 31
|
Quote:
A B C Male 65 2M65 Is there a formula that can calculate that in column C I have 2M's instead of me writing it as M65-M65 Thanks in advance |
|||
|
|
|
|
|
#10 | ||||
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
|
Quote:
2M65-4M45 etc. |
||||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|