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 Mar 21st, 2002, 07:08 AM   #1
SB
New Member
 
Join Date: Mar 2002
Posts: 18
Default

Site Certified operator
1 yes
yes
no
2 yes
no
3 no
yes
4 no
no

Can anyone come up with a function that will count how many of the sites in column one have at least one "Yes" in the corresponding certified operator cells?

Sites can have multiple operators but any combination could be certified. If one site has 3 certified operators it should only count 1.

Answer for above example would be 3.

I've been struggling with this one for awhile, any help is greatly appreciated.
SB is offline   Reply With Quote
Old Mar 21st, 2002, 07:22 AM   #2
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Just need to know for sure if
"A" is correct or "B" See Below
Please Reply

"A"
Site Certified operator
1 yes
yes
no
2 yes
no
3 no
yes
4 no
no


"B"
Site Certified operator
1
yes
yes
no
2
yes
no
3
no
yes
4
no
no


Are you familiar with macros???
If not which Row does this list begin in?
Which Column?
Tom Schreiner is offline   Reply With Quote
Old Mar 21st, 2002, 07:39 AM   #3
SB
New Member
 
Join Date: Mar 2002
Posts: 18
Default

Column 1____Column 2
1___________yes
____________yes
____________no
2___________yes
____________no
3___________no
____________yes
4___________no
____________no
SB is offline   Reply With Quote
Old Mar 21st, 2002, 07:45 AM   #4
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Are you familiar with macros?
Your problem is easy to solve, but
I need to know if I can skip all the details with my next reply.
Tom Schreiner is offline   Reply With Quote
Old Mar 21st, 2002, 07:49 AM   #5
SB
New Member
 
Join Date: Mar 2002
Posts: 18
Default

No I'm not very familiar with macros. I'm fairly new to this, I was trying to create a function involving arrays that would solve it.
SB is offline   Reply With Quote
Old Mar 21st, 2002, 07:56 AM   #6
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-03-21 06:08, SB wrote:
Site Certified operator
1 yes
yes
no
2 yes
no
3 no
yes
4 no
no

Can anyone come up with a function that will count how many of the sites in column one have at least one "Yes" in the corresponding certified operator cells?

Sites can have multiple operators but any combination could be certified. If one site has 3 certified operators it should only count 1.

Answer for above example would be 3.

I've been struggling with this one for awhile, any help is greatly appreciated.
Consider your sample (added an additional row) to be A2:C6.

{1,"yes","no";
2,"yes","no";
3,"no","yes";
4,"no","no";
5,"yes","yes"}

What follows will give you the desired count:

=SUMPRODUCT((1*((B2:B6="yes")+(C2:C6="yes"))))-SUMPRODUCT((B2:B6="yes")*(C2:C6="yes"))
Aladin Akyurek is offline   Reply With Quote
Old Mar 21st, 2002, 07:58 AM   #7
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default


It's not a good idea to open and run a macro from someone you do not know but I'll send it to you anyway in case you want to use it.
Tom Schreiner is offline   Reply With Quote
Old Mar 21st, 2002, 08:27 AM   #8
SB
New Member
 
Join Date: Mar 2002
Posts: 18
Default

Thanks, the formula works and is close to what I need. However, the information I have is listed differently then you have it. Sorry, I was probably not clear initally.

You wrote the data from A2:C6 as;

1____yes____no
2____yes____no
3____no_____yes
4____no_____no
5____yes____yes

When in fact it is from A2:B11;

1____yes
_____no
2____Yes
_____no
3____no
_____yes
4____no
_____no
5____yes
_____yes

Each number (1 to 5) can have any number of 'yes' or 'no' responses listed vertically. The formula needs to count only 1 if any number of 'yes' is found in the responses for each number.
SB is offline   Reply With Quote
Old Mar 21st, 2002, 08:32 AM   #9
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Hi
Here is the Macro for you
Since you do not know how to work with macros, you will have to follow these direction carefully or find someone to edit it for you if necc.

List your Site numbers in Column A beginning on Row #2

List the Yes/No data in Column B beginning with Row #2

From Excel hit Alt/F11 to open the Visual Basic Environment

Click on 'Insert' on your Menu Bar up top

Copy everything Between the ################
and paste it exactly as is

close the Visual Basic Environment and From Excel hit Alt/F8 to open the macro box.

Choose "Yes_No_macro" and click on run.

Make sure you are viewing the sheet which you are wanting to process

Will list all sites with a certified operator in column "C"

Will give you the total number of certified operators in column "D"

Hope this helps

Copy below between '#########################

'##############################################################################
Sub Yes_No_macro()
Dim X
Dim Y
Dim Z
Dim PutInC1
Dim Certified As Boolean
Dim CurrentSite
PutInC1 = 2
Z = 1
Range("A1").Value = "Site Numbers"
Range("B1").Value = "Certified?"
For X = 3 To 65500
Certified = False
If Range("A" & X).Value > 0 Then
CurrentSite = Range("A" & X).Value
Y = X + 1
If LCase(Trim(Range("B" & X).Value)) = "yes" Then _
Certified = True
Do Until Range("A" & Y).Value > 0
If Y > 65500 Then Exit Do
If LCase(Trim(Range("B" & Y).Value)) = "yes" Then
Certified = True
End If
Y = Y + 1
Loop
X = Y - 1
If Certified = True Then
Z = Z + 1
PutInC1 = PutInC1 + 1
Range("C1").Value = "Cite Certified List"
Range("C" & PutInC1).Value = CurrentSite
End If
End If
Next
Done:
Range("D1").Value = "Number of Sites with Certified Operators = " & Z - 1

End Sub
'##############################################################################

[ This Message was edited by: TsTom on 2002-03-21 07:36 ]
Tom Schreiner is offline   Reply With Quote
Old Mar 21st, 2002, 08:54 AM   #10
SB
New Member
 
Join Date: Mar 2002
Posts: 18
Default

Wow. I never new excel could do anything like that, I never would have figured that out. Thanks a lot. I have a lot to learn.
SB 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:16 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