Modify a Formulae in Access that creates a formulae in Excel

JohnLee

Registered User.
Local time
Today, 10:25
Joined
Mar 8, 2007
Messages
692
Good day folks,

I have code that exports a qry to Excel as a spreadsheet. With the help of this forum I have the following line of code that identifies the range and gets the last cell with data in it and then sums up the data in all the cells above the last cell. The problem is I want the sum to always begin at row 3, cell A3 and not cell A1, because there is a data in the first 2 rows that should not form part of this calculation. Any help in how to modify this to achieve that would be gratefully received:

Code:
Objsheet.Range("A" & LastRow + 1).FormulaR1C1 = "=SUM(R[-" & LastRow & "]C:R[-1]C)"

John
 
try this:

objSheet.Range("A3:A" & lastrow + 1).FormulaR1C1 = "=SUM(R[-" & lastrow & "]C:R[-1]C)"
 
Hi SpentGeezer,

Thanks for you help, however I get a circular error in Excel when I run the code!

I entered the amended code exactly as you provided, any ideas.

Thanks

John
 

Users who are viewing this thread

Back
Top Bottom