Yes in a normal module should be fine
Here is another UDF.
http://www.ozgrid.com/VBA/sum-count-cells-by-color.htm
As I say if the cells are coloured by conditional formatting then it won't work, you will need to look at summing based the criteria in the CF.