I'm getting error messages (like 'Expected End of sentence') when trying to enter (in VBA) what seems like it should be a simple formula. The full macro inserts columns with billed amounts for each new month, and i want to decrement all month's billed amounts from a starting total (PO amount). i'm new to VBA and not savvy to the syntax of formula.r1c1 yet.
Here's a section of the subroutine:
col = Selection.Columns.Count
row = Selection.Rows.Count
Set myrange = Selection.Offset(0, 1).Resize(, col - 2)
Set mytotals = myrange.Offset(0, col - 1).Resize(, 1)
mytotals.Formula = "=sum(" & myrange.Rows(1).Address(False, False) & ")"
mytotals.FormulaR1C1 = "=sum(" & myrange.Rows(1).Address(False, False) & ")" & "-r[1]c[1-col]"
THe first mytotals.formula statement works fine, but only yields the subtotal of billed amounts. When I try to subtract the starting amount in the next statement, no amount of retyping yielded successful results (all errors). I've created a work-around by setting the subtotal of billed amounts in an unused cell, then writing a simple formula to get the difference, but i want to be able to do it in one step in case i don't have the luxury of a blank cell in future applications.
I would be grateful of any advice or help offered.
Thx, Morty
Here's a section of the subroutine:
col = Selection.Columns.Count
row = Selection.Rows.Count
Set myrange = Selection.Offset(0, 1).Resize(, col - 2)
Set mytotals = myrange.Offset(0, col - 1).Resize(, 1)
mytotals.Formula = "=sum(" & myrange.Rows(1).Address(False, False) & ")"
mytotals.FormulaR1C1 = "=sum(" & myrange.Rows(1).Address(False, False) & ")" & "-r[1]c[1-col]"
THe first mytotals.formula statement works fine, but only yields the subtotal of billed amounts. When I try to subtract the starting amount in the next statement, no amount of retyping yielded successful results (all errors). I've created a work-around by setting the subtotal of billed amounts in an unused cell, then writing a simple formula to get the difference, but i want to be able to do it in one step in case i don't have the luxury of a blank cell in future applications.
I would be grateful of any advice or help offered.
Thx, Morty