If the fill colour is from conditional formatting then it may be a lot more difficult.
Actually, I thnk that makes it easier. Because you can then count the 'condition' instead of the color..
But we do need more specific information.
How exactly are the cells highlighted?
Is this for a task you're 'planning' in the future, or for some data that already exists you need to count?
If it's something you're planning in the future, you'd be best off using an alternate method to 'flag' which cells to sum.
Like putting an X or any text value you like in an adjescent column.
Then you can use simple SUMIF functions.