combine macro that sums per color with a specific date (day)

lelebrasa

New member
Joined
Sep 25, 2014
Messages
2
Reaction score
0
Points
0
hi Gurus...LOL
I have a plan that sums my production per colors, works, but it is like this:

job.......due .................cut......qty
Job1.....22/09.................18/09......
job2.....22/09..................19/09.....
job3....22/09...................19/09.....
job4....22/09...................18/09.....
job5....22/09...................19/09.....


after rum the macro, I got as answer obvious green 55, red 70

but this is not an accurate result, the job was due for the same day, but was produced in different days (18 & 19)

that is a way to separate by date? maybe insert a sumif to compare dates? to have something like this:

Cut.........18/09....19/09
Green.......25.........30
Red.........30.........40

tkx for help me

Leandro Jorge




using the following funcion:

Function SumByColor(CellColor As Range, SumRange As Range)
Dim myCell As Range
Dim iCol As Integer
Dim myTotal
iCol = CellColor.Interior.ColorIndex
For Each myCell In SumRange
If myCell.Interior.ColorIndex = iCol Then
myTotal = WorksheetFunction.Sum(myCell) + myTotal
End If
Next myCell
SumByColor = myTotal
End Function
 

lelebrasa

New member
Joined
Sep 25, 2014
Messages
2
Reaction score
0
Points
0
guys sorry, I don't use forums often, I just thought the forums were independent each order, that why I even made easy to everyone, I kept the same title.

the problem is, my solutions seems not be possible.

tkx anyway
 

WizzardOfOz

New member
Joined
Sep 4, 2013
Messages
184
Reaction score
0
Points
0
Location
Australia
Excel Version(s)
Office 365
Create a UDF as follows

Code:
Function IColor(CellColor As Range) As Long
    IColor = CellColor.Interior.ColorIndex    'can get fancy and return a text colour here but quick and easy fix here
End Function

Then add a column =IColor(D2)

Then run a pivot table on that.
 
Top