Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SYNTAX FOR SUM FORMULA WITH VARIABLE 1

Status
Not open for further replies.

Evil8

MIS
Mar 3, 2006
313
US
I'm getting an error on the last line. Can anyone point out my error. I'm pretty new at this, but getting better.

'Last Row
Dim LastRow As Long

'Recalculate the LAST real row
LastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row

'Set Column and Row Totals
Range("J" & LastRow + 2).Select
ActiveCell.FormulaR1C1 = "=SUM(J5:J + LastRow)
 


Hi,
Code:
 ActiveCell.FormulaR1C1 = "=SUM(J5:J + " & LastRow & ")"


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 




Loose the R1C1...
Code:
 ActiveCell.Formula = "=SUM(J5:J + " & LastRow & ")"

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip, in either case I get a Name error: The formula contains unrecognized text.

On the test spreadsheet it looks like:

With R1C1
=SUM('J5':J + 92)

Without R1C1
=SUM(J5:J + 92)
 




Sorry,
Code:
ActiveCell.Formula = "=SUM(J5:J" & LastRow & ")"

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top