MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 22nd, 2002, 09:02 AM   #1
ageeb
New Member
 
Join Date: May 2002
Posts: 31
Default

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
ageeb is offline   Reply With Quote
Old May 22nd, 2002, 09:11 AM   #2
sann0638
Board Regular
 
Join Date: Mar 2002
Posts: 175
Default

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.
sann0638 is offline   Reply With Quote
Old May 22nd, 2002, 09:17 AM   #3
IML
MrExcel MVP
 
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
Default

By formula you could use
=LEN(C1)-LEN(SUBSTITUTE(UPPER(C1),"M",""))

to see how many M's are in C1.

good luck.
IML is offline   Reply With Quote
Old May 22nd, 2002, 09:23 AM   #4
philR
Board Regular
 
Join Date: Feb 2002
Location: Sheffield, UK
Posts: 249
Default

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!
philR is offline   Reply With Quote
Old May 22nd, 2002, 09:23 AM   #5
ageeb
New Member
 
Join Date: May 2002
Posts: 31
Default

Quote:
On 2002-05-22 08:11, sann0638 wrote:
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.
I am not sure if I understood what you meant
ageeb is offline   Reply With Quote
Old May 22nd, 2002, 09:24 AM   #6
philR
Board Regular
 
Join Date: Feb 2002
Location: Sheffield, UK
Posts: 249
Default

Wow, IML just seen your reply. Very clever! Wish I had thought of that
philR is offline   Reply With Quote
Old May 23rd, 2002, 03:25 AM   #7
ageeb
New Member
 
Join Date: May 2002
Posts: 31
Default

Quote:
On 2002-05-22 08:24, philR wrote:
Wow, IML just seen your reply. Very clever! Wish I had thought of that
Hi

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
ageeb is offline   Reply With Quote
Old May 23rd, 2002, 03:33 AM   #8
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-05-23 02:25, ageeb wrote:
Quote:
On 2002-05-22 08:24, philR wrote:
Wow, IML just seen your reply. Very clever! Wish I had thought of that
Hi

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
=SUMPRODUCT((LEN(C1:C20)-LEN(SUBSTITUTE(UPPER(C1:C20),"M",""))))
Aladin Akyurek is offline   Reply With Quote
Old May 23rd, 2002, 03:42 AM   #9
ageeb
New Member
 
Join Date: May 2002
Posts: 31
Default

Quote:
On 2002-05-23 02:33, Aladin Akyurek wrote:
Quote:
On 2002-05-23 02:25, ageeb wrote:
Quote:
On 2002-05-22 08:24, philR wrote:
Wow, IML just seen your reply. Very clever! Wish I had thought of that
Hi

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
=SUMPRODUCT((LEN(C1:C20)-LEN(SUBSTITUTE(UPPER(C1:C20),"M",""))))
Thanks 4 your help, but I have another question if the database looks like this

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

ageeb is offline   Reply With Quote
Old May 23rd, 2002, 04:03 AM   #10
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-05-23 02:42, ageeb wrote:
Quote:
On 2002-05-23 02:33, Aladin Akyurek wrote:
Quote:
On 2002-05-23 02:25, ageeb wrote:
Quote:
On 2002-05-22 08:24, philR wrote:
Wow, IML just seen your reply. Very clever! Wish I had thought of that
Hi

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
=SUMPRODUCT((LEN(C1:C20)-LEN(SUBSTITUTE(UPPER(C1:C20),"M",""))))
Thanks 4 your help, but I have another question if the database looks like this

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
That would complicate the formula and make it very expensive qua time, in particular when you have entries like:

2M65-4M45

etc.
Aladin Akyurek is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:03 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes