Ok thanks, apologies if I'm a bit slow at this but I have two modules, see below:
1st Module
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
''''''''''''''''''''''''''''''''''''''
'Written by Ozgrid Business Applications
'www.ozgrid.com
'Sums or counts cells based on a specified fill color.
'''''''''''''''''''''''''''''''''''''''
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
ColorFunction = vResult
End Function
2nd Module
Sub Save_Hols()
'
' Save_Hols Macro
'
'
Range("D7").FormulaR1C1 = "=colorfunction(R[-5]C[5],RC[4]:RC[34])"
Range("D8").FormulaR1C1 = "=colorfunction(R[-6]C[5],RC[4]:RC[34])"
Range("D9").FormulaR1C1 = "=colorfunction(R[-7]C[5],RC[4]:RC[34])"
Range("D10").FormulaR1C1 = "=colorfunction(R[-8]C[5],RC[4]:RC[34])"
Range("D11").FormulaR1C1 = "=colorfunction(R[-9]C[5],RC[4]:RC[34])"
Range("D12").FormulaR1C1 = "=colorfunction(R[-10]C[5],RC[4]:RC[34])"
Range("D13").FormulaR1C1 = "=colorfunction(R[-11]C[5],RC[4]:RC[34])"
Range("D14").FormulaR1C1 = "=colorfunction(R[-12]C[5],RC[4]:RC[34])"
Range("D15").FormulaR1C1 = "=colorfunction(R[-13]C[5],RC[4]:RC[34])"
Range("D16").FormulaR1C1 = "=colorfunction(R[-14]C[5],RC[4]:RC[34])"
Range("D17").FormulaR1C1 = "=colorfunction(R[-15]C[5],RC[4]:RC[34])"
Range("D18").FormulaR1C1 = "=colorfunction(R[-16]C[5],RC[4]:RC[34])"
Range("D19").FormulaR1C1 = "=colorfunction(R[-17]C[5],RC[4]:RC[34])"
Range("D20").FormulaR1C1 = "=colorfunction(R[-18]C[5],RC[4]:RC[34])"
Range("D21").FormulaR1C1 = "=colorfunction(R[-19]C[5],RC[4]:RC[34])"
Range("D22").FormulaR1C1 = "=colorfunction(R[-20]C[5],RC[4]:RC[34])"
Range("F7").FormulaR1C1 = "=colorfunction(R[-5]C[9],RC[2]:RC[32])"
Range("F8").FormulaR1C1 = "=colorfunction(R[-6]C[9],RC[2]:RC[32])"
Range("F9").FormulaR1C1 = "=colorfunction(R[-7]C[9],RC[2]:RC[32])"
Range("F10").FormulaR1C1 = "=colorfunction(R[-8]C[9],RC[2]:RC[32])"
Range("F11").FormulaR1C1 = "=colorfunction(R[-5]C[9],RC[2]:RC[32])"
Range("F12").FormulaR1C1 = "=colorfunction(R[-10]C[9],RC[2]:RC[32])"
Range("F13").FormulaR1C1 = "=colorfunction(R[-11]C[9],RC[2]:RC[32])"
Range("F14").FormulaR1C1 = "=colorfunction(R[-12]C[9],RC[2]:RC[32])"
Range("F15").FormulaR1C1 = "=colorfunction(R[-13]C[9],RC[2]:RC[32])"
Range("F16").FormulaR1C1 = "=colorfunction(R[-14]C[9],RC[2]:RC[32])"
Range("F17").FormulaR1C1 = "=colorfunction(R[-15]C[9],RC[2]:RC[32])"
Range("F18").FormulaR1C1 = "=colorfunction(R[-16]C[9],RC[2]:RC[32])"
Range("F19").FormulaR1C1 = "=colorfunction(R[-17]C[9],RC[2]:RC[32])"
Range("F20").FormulaR1C1 = "=colorfunction(R[-18]C[9],RC[2]:RC[32])"
Range("F21").FormulaR1C1 = "=colorfunction(R[-19]C[9],RC[2]:RC[32])"
Range("F22").FormulaR1C1 = "=colorfunction(R[-20]C[9],RC[2]:RC[32])"
Range("G7").FormulaR1C1 = "=colorfunction(R[-5]C[14],RC[1]:RC[31])"
Range("G8").FormulaR1C1 = "=colorfunction(R[-6]C[14],RC[1]:RC[31])"
Range("G9").FormulaR1C1 = "=colorfunction(R[-7]C[14],RC[1]:RC[31])"
Range("G10").FormulaR1C1 = "=colorfunction(R[-8]C[14],RC[1]:RC[31])"
Range("G11").FormulaR1C1 = "=colorfunction(R[-9]C[14],RC[1]:RC[31])"
Range("G12").FormulaR1C1 = "=colorfunction(R[-10]C[14],RC[1]:RC[31])"
Range("G13").FormulaR1C1 = "=colorfunction(R[-11]C[14],RC[1]:RC[31])"
Range("G14").FormulaR1C1 = "=colorfunction(R[-12]C[14],RC[1]:RC[31])"
Range("G15").FormulaR1C1 = "=colorfunction(R[-13]C[14],RC[1]:RC[31])"
Range("G16").FormulaR1C1 = "=colorfunction(R[-14]C[14],RC[1]:RC[31])"
Range("G17").FormulaR1C1 = "=colorfunction(R[-15]C[14],RC[1]:RC[31])"
Range("G18").FormulaR1C1 = "=colorfunction(R[-16]C[14],RC[1]:RC[31])"
Range("G19").FormulaR1C1 = "=colorfunction(R[-17]C[14],RC[1]:RC[31])"
Range("G20").FormulaR1C1 = "=colorfunction(R[-18]C[14],RC[1]:RC[31])"
Range("G21").FormulaR1C1 = "=colorfunction(R[-19]C[14],RC[1]:RC[31])"
Range("G22").FormulaR1C1 = "=colorfunction(R[-20]C[14],RC[1]:RC[31])"
End Sub
Then in my cell I have the =colorfunction(I2,H7:AL7)
H7:AL7 being one row that it counts the color in cell I2, however I also want it to count the colour in other rows, namely H27:AL27 etc.
I hope I'm making sense, my laptop will not allow me to use the HTML Maker otherwise I would have done that.
Thanks.