G
Guest
Hello and thanks for any assistance proffered.
(I am on a steep part of a learning curve with VBA language/syntax)
I have the following (working) code as part of a procedure. It is an
addition to a hacked about hybrid version of Ron de Bruin's
Copy_To_Worksheets procedure.
The sub is fake for the sake of a working demo.
Sub formulaPut()
' Earlier definitions
Dim AnalStart As Long, AnalEnd As Long, cSheet As String
Dim SumLastRow As Long, FormulaRow As Long, nCol As Long
' Set in a definitions sheet
AnalStart = 3 ' "Start Column"
AnalEnd = 12 ' "End Column"
cSheet = "Sheet1" ' (for the sake of demo)
' Starting at row 2
SumLastRow = 9 ' LastRow() calculation
FormulaRow = SumLastRow + 2
' Add formulae and make them bold
Worksheets(cSheet).Activate
For nCol = AnalStart To AnalEnd
Cells(FormulaRow, nCol).FormulaR1C1 = _
"=sum(R2C" & nCol & ":" & "R" & SumLastRow & "C" & nCol & ")"
Cells(FormulaRow, nCol).Font.Bold = True
Cells(FormulaRow, nCol).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Next nCol
End Sub
This produces something like =SUM($F$2:$F$39), which is perfectly OK.
However, I would prefer =SUM(F2:F39) or $F2:$F39), so if anyone uses a
list on the sheet created, the formula SUM's on the (shorter) list.
Is this possible?
regards, Alan
(I am on a steep part of a learning curve with VBA language/syntax)
I have the following (working) code as part of a procedure. It is an
addition to a hacked about hybrid version of Ron de Bruin's
Copy_To_Worksheets procedure.
The sub is fake for the sake of a working demo.
Sub formulaPut()
' Earlier definitions
Dim AnalStart As Long, AnalEnd As Long, cSheet As String
Dim SumLastRow As Long, FormulaRow As Long, nCol As Long
' Set in a definitions sheet
AnalStart = 3 ' "Start Column"
AnalEnd = 12 ' "End Column"
cSheet = "Sheet1" ' (for the sake of demo)
' Starting at row 2
SumLastRow = 9 ' LastRow() calculation
FormulaRow = SumLastRow + 2
' Add formulae and make them bold
Worksheets(cSheet).Activate
For nCol = AnalStart To AnalEnd
Cells(FormulaRow, nCol).FormulaR1C1 = _
"=sum(R2C" & nCol & ":" & "R" & SumLastRow & "C" & nCol & ")"
Cells(FormulaRow, nCol).Font.Bold = True
Cells(FormulaRow, nCol).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Next nCol
End Sub
This produces something like =SUM($F$2:$F$39), which is perfectly OK.
However, I would prefer =SUM(F2:F39) or $F2:$F39), so if anyone uses a
list on the sheet created, the formula SUM's on the (shorter) list.
Is this possible?
regards, Alan