P304 = 2

P305 = Total

P306 = 3

P307 = 7

P308 = 2

P309 = Total

Cell P309 should autosum 3, 7 and 2 only, NOT 2, 2(first Total), 3,7, and 2. The values of the cells are based on formulas which reference a database. Therefore, the word "Total" appears randomly in the range based on the data refresh. Please help!

VBA code:

- 'change sum in subtotal to formula
- Set sumrange = Range("P304:Q585")
- For Each Cell In sumrange
- If Cell.value = "sum" Then
- Cell.Formula = "=Sum(" & Range(Cell.Offset(-1, 0), Cell.Offset(-1, 0).End(xlUp)).Address & ")"
- End If
- Next