countcolour and sumby colour

countcolour and sumby colour

I am getting quite desperate now. 

Zoho is the perfect platform for a spreadsheet I am trying to move from excel local to a shared sheet but I cant get two formula's to work

Function CountCcolor(range_data As Range, criteria As Range) As Long
Application.Volatile
Dim datax As Range
Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
CountCcolor = CountCcolor + 1
End If
Next datax
End Function

and

Function SumByColor(CellColor As Range, SumRange As Range)
Application.Volatile
Dim ICol As Integer
Dim TCell As Range
ICol = CellColor.Interior.ColorIndex
For Each TCell In SumRange
If ICol = TCell.Interior.ColorIndex Then
SumByColor = SumByColor + TCell.Value
End If
Next TCell
End Function

Would anyone be able to help me get there working our something that I could substitute with?