Ok, the following function (formula) will sum the cells in a range that are the same colour as the cell you put the function in.
Function ColCount(wsRng As Range)
Dim Cell As Range
Application.Volatile
wsCol = Application.Caller.Interior.ColorIndex
For Each Cell In wsRng
If Cell.Interior.ColorIndex = wsCol Then ColCount = ColCount + Cell.Value
Next
End Function
-To use it, open the VBA window in the workbook you want to use this in.
-Right click the Workbook in the Project Explorer (the left hand window in the VBA editor) and Insert a module.
-Double click the module
-Paste the code above into the right hand bit of the window (as per screenshot below)
![]()
You can now use =ColCount(Your range) as a formula like you would SUM.
The function counts the cells in a range that are the same colour as the cell it is put in.
So if you want to sum Orange cells, write the formula in a cell and then colour that cell orange.
There is a way to populate the 2nd table without doing that first though.
I'll just put the kid to bed and then teach you array formulas!
Once again all, thanks for the reply's, i don't think i explained it well, i think i will explain exactly what i am trying to do, This is sheet 1..
and this is sheet 2
M/O/L stand for More, On Time, Less and equates to time taken in the estimates time and actual time, so F2 has the letter L in it because the actual time taken was less the estimated time. This is not done by an equation though, What would this equation be, something like
=IF(D2>E2,"L","M",if(D2=E2,"O","")), Although that doesnt work, The first bit says if the number in E2 is greater than D2 then it puts and L in, if not then it puts an M in, on the second bit if(D2=E2,"O","")) im trying to say if D2 and E2 are the same then put an O in but that doesnt work, Any ideas on this one?
Also on sheet 2 i have done this equation =COUNTIF(Sheet1!C2:C8,"Bottle") for #job packed which effectively searches for the word bottle and counts it, In C2 what i want to do is put the amount of "BOTTLE" jobs were packed on time and then i can repeat that for the amount of bottle jobs not on time and early, I have tried a few ways of trying to nest IF with Countif but cannot seem to get them to work. Any idea's?
Thanks guys.
Its because you haven't told it to look on the Rota sheet. I haven't tested this as I'm on my phone but try putting 'rota'! or rota! in front of the R, but still within the speech marks.
I'm not sure I follow you completely but it sounds like a pivot table would be a good starting point
Yeah, that's possible, I have something similar set up in a spreadsheet i did at work a couple of weeks ago.
It'd be easier if you could send me the spreadsheet to work on though and then i'll explain it.
edit:
It is possible but you're making it really complicated, i'm halfway there but beginning to wonder how to explain all the functions i'm using!
You'd be better of restructuring the way the data is stored in the first place.
Is the "data mine" based on something in real life or just how you envisioned it coming out the database or whatever you hold that information in?