![]() |
![]() |
|
|||||||
| 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 |
|
Board Regular
Join Date: Apr 2002
Posts: 76
|
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 |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Hellas
Posts: 553
|
__________________
Best Regards Andreas
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Posts: 76
|
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 |
|
|
|
|
|
#4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
you have something like this;
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 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Posts: 76
|
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 |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Mar 2002
Location: Hellas
Posts: 553
|
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
|
|
|
|
|
|
#7 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
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 |
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Apr 2002
Posts: 76
|
Oh you absolute honey!! Thanks, it works! Janie xxxxxxxx xxxxxx |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|