Hi all, I am trying to use the Range.Formula or Range.FormulaR1C1 methods to insert a formula into one of my sheets. The (partial) code I currently have is below.
This results in the formula "=SUM(I$2:I821)" being placed in cell I823. I would like to know if there is a way to adjust the code so that it returns the formula "=SUM(I2:I821)". It's a minor change but it would help, and I would use any information provided to adjust other portions of the code. Since these sheets are audited every month, I have to have a formula that will allow an auditor without VBA knowledge to backtrace how I arrived at various numbers (so I can't just sum the values inside VBA and drop the answer in the cell). In case anyone's wondering, the AcctSign and AcctNoSign variables are constants that I declared earlier so I wouldn't have to keep writing all the nonsense associated with the Accounting number format. Does anyone have any ideas? Hopefully it's something simple that I'm just missing! Thank you very much.
Code:
Set Gross = Range("A1", Range("A1").End(xlToRight)).Find("Grossdollars")
Range(Gross.Offset(1), Gross.End(xlDown)).NumberFormat = AcctNoSign
SumRowTop = Gross.Offset(1).Row
With Gross.End(xlDown).Offset(2, -1)
.Value = "Total"
.Font.Bold = True
.HorizontalAlignment = xlRight
With .Offset(, 1)
[COLOR=#ff0000] .FormulaR1C1 = "=SUM(R" & SumRowTop & "C:R[-2]C)"[/COLOR]
.NumberFormat = AcctSign
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlDouble: End With: End With
This results in the formula "=SUM(I$2:I821)" being placed in cell I823. I would like to know if there is a way to adjust the code so that it returns the formula "=SUM(I2:I821)". It's a minor change but it would help, and I would use any information provided to adjust other portions of the code. Since these sheets are audited every month, I have to have a formula that will allow an auditor without VBA knowledge to backtrace how I arrived at various numbers (so I can't just sum the values inside VBA and drop the answer in the cell). In case anyone's wondering, the AcctSign and AcctNoSign variables are constants that I declared earlier so I wouldn't have to keep writing all the nonsense associated with the Accounting number format. Does anyone have any ideas? Hopefully it's something simple that I'm just missing! Thank you very much.