I formatted the cells yellow to highlight the totals, but the list of data is always different and I want a script that will find the yellow formatted cells and insert the SUM function. I'm sure its simple but I've never written any script that dealt with cell color so I'm pretty ignorant.
You might like to try this macro code. It covers the range A1:G50 , (change as required).
When it finds a yellow cell it sums all cells above it up to the first empty cell
Dim x As Range
For Each cell In Range("A1:G50")
If cell.Interior.ColorIndex = 6 Then
cell.Value = "=sum(" & cell.Offset(-1, 0).Address & ":" & cell.Offset(-1, 0).End(xlUp).Address & ")"