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 14th, 2002, 06:09 AM   #1
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default


In Row 1 of my column I have total amount of customers, in row 2 I have total amount of calls and in row 3 I have the date. The date row cells are coloured differently depending on what agent worked. There is no discernible pattern to this colouring.

I need a formula that will look along the coloured row and sum the total mount of customers (Row 1) for each colour. So basically, it's like a SUMIF but the criteria is colour. Is this possible or will I need to go into VBA?

And if I do need to go into VBA, what do I do?

Thanks for your help

Janie

xx
buntykins is offline   Reply With Quote
Old May 14th, 2002, 06:20 AM   #2
sen_edp
Board Regular
 
sen_edp's Avatar
 
Join Date: Mar 2002
Location: Hellas
Posts: 553
Default


TRY A UDF BY ERLADSEN

http://www.erlandsendata.no/english/...sumbycolor.htm


__________________
Best Regards
Andreas
sen_edp is offline   Reply With Quote
Old May 14th, 2002, 06:32 AM   #3
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default

Cool thanks, except I dont want to add the coloured cells together, I want to add the ones above it. Also, how would I make this work? Where would I put it? How would I make it run?

Janie
buntykins is offline   Reply With Quote
Old May 14th, 2002, 06:45 AM   #4
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Quote:
On 2002-05-14 05:09, buntykins wrote:

In Row 1 of my column I have total amount of customers, in row 2 I have total amount of calls and in row 3 I have the date. The date row cells are coloured differently depending on what agent worked. There is no discernible pattern to this colouring.

I need a formula that will look along the coloured row and sum the total mount of customers (Row 1) for each colour. So basically, it's like a SUMIF but the criteria is colour. Is this possible or will I need to go into VBA?

And if I do need to go into VBA, what do I do?

Thanks for your help

Janie

xx
Hi Janie, if I understand you correctly then
you have something like this;
Microsoft Excel - Book4_______________Running: xl2000 : OS = Windows (32-bit) 4.10
(F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp
E3= =SumByColour(C3,C$2:C$15)
*ABCDE
1CustomersCallsDateResultUser Defined Function
216102/01/02:alert("=SumByColour(C2,C$2:C$15)")>27 =SumByColour(C2,C$2:C$15)
31502/02/02:alert("=SumByColour(C3,C$2:C$15)")>27 =SumByColour(C3,C$2:C$15)
451102/03/02:alert("=SumByColour(C4,C$2:C$15)")>17 =SumByColour(C4,C$2:C$15)
56502/04/02:alert("=SumByColour(C5,C$2:C$15)")>49 =SumByColour(C5,C$2:C$15)
69102/05/02:alert("=SumByColour(C6,C$2:C$15)")>16 =SumByColour(C6,C$2:C$15)
745202/06/02:alert("=SumByColour(C7,C$2:C$15)")>47*
881602/07/02:alert("=SumByColour(C8,C$2:C$15)")>17*
91902/08/02:alert("=SumByColour(C9,C$2:C$15)")>27*
1091002/09/02:alert("=SumByColour(C10,C$2:C$15)")>27*
1112402/10/02:alert("=SumByColour(C11,C$2:C$15)")>17*
1243202/11/02:alert("=SumByColour(C12,C$2:C$15)")>49*
137902/12/02:alert("=SumByColour(C13,C$2:C$15)")>16*
142702/13/02:alert("=SumByColour(C14,C$2:C$15)")>47*
159802/14/02:alert("=SumByColour(C15,C$2:C$15)")>17*
Sheet4

To see the formula in the cells just click on the cells hyperlink

The above image was automatically generated by [HtmlMaker V1.23]
If you want this code, click here and Colo will email the file to you.
This code was graciously allowed to be modified: by Ivan F Moala All credit to Colo


What you need to do is setup a UDF
User defined Function as suggested by Andreas

The UDF in your case requires something a
little different as you are not counting
colour cells but Column 1 cells ?? See above.

Follow these instructions to get the UDF in
1) Press Alt + F11 - takes you into the VBA Editor
2) Press Ctrl + 4 - takes you to the Project explorer
3) Right clcik on any of the Objects > Insert > Module
4) Cut & Paste this Code


UDF:


Function SumByColour(CellColour As Range, SumRange As Range)
Dim cell As Range
Dim SumColour As Double
Dim MySum

Application.Volatile
'If CellColour.Cells > 1 Then Exit Function
SumColour = CellColour.Interior.ColorIndex

For Each cell In SumRange
If cell.Interior.ColorIndex = SumColour Then
MySum = MySum + cell.Offset(0, -2)
End If
Next cell
SumByColour = MySum

End Function




If you require further then just Post


__________________
Kind Regards,
Ivan F Moala From the City of Sails
Ivan F Moala is offline   Reply With Quote
Old May 14th, 2002, 06:51 AM   #5
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default

Ivan,

Thanks that's great. So basically I've opened a module and pasted that in? So now when I want to use it, what do I do?

Thanks

Janie
xxxxx
buntykins is offline   Reply With Quote
Old May 14th, 2002, 07:03 AM   #6
sen_edp
Board Regular
 
sen_edp's Avatar
 
Join Date: Mar 2002
Location: Hellas
Posts: 553
Default

Hello Janie,

Go to the menus-insert function-function category-user defined-function name-sumbycolour

and put it is as Ivan shows in his sheet in the appropriate cell.


__________________
Best Regards
Andreas
sen_edp is offline   Reply With Quote
Old May 14th, 2002, 07:06 AM   #7
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Quote:
On 2002-05-14 05:51, buntykins wrote:
Ivan,

Thanks that's great. So basically I've opened a module and pasted that in? So now when I want to use it, what do I do?

Thanks

Janie
xxxxx
If you have a look @ the Post I sent you will
see I have the UDF setup in Column D (Results) and the Formula next to it E.
eg in D2

=SumByColour(C2,C$2:C$15)
Where C2 is the Colour to search for
C$2:C$15 is the Colour Range

The UDF searchs the colour range for a match
on C2 and then Looks @ Column A and adds this
up.


Note: The UDF is Avail to you via the normal
Paste Function button > under User Defined.

Post soon if you still need help...BUT
just look @ the Posted example above....
sleep time soon

__________________
Kind Regards,
Ivan F Moala From the City of Sails
Ivan F Moala is offline   Reply With Quote
Old May 14th, 2002, 07:08 AM   #8
buntykins
Board Regular
 
Join Date: Apr 2002
Posts: 76
Default


Oh you absolute honey!!

Thanks, it works!

Janie

xxxxxxxx
xxxxxx
buntykins 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 02:47 PM.


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