Are you creating a brand new excel spreadsheet each time you execute the code?
I did something similar but found I had to write data to a template
spreadsheet using CopyFromRecordset. In the template, I created a Sum
function in the appropriate column and wrote the data above that cell. The
sum function range automatically adjusts to your recordset.
Example:
Cell A1 - Header
Cell A2 - Blank -- use CopyFromRecordset and write to this cell
Cell A3 - Sum function
"Gerry" wrote:
> Hello,
> I created an excel sheet by code, based on an access query.
> For one of these collumns I have to make a sum of this collumn and put
> the result at the bottom of that collumn (the amount of rows varies
> with every launch of the query). I don't know how to do it in code.
> Can someone help me with this? When I register a macro in excel which
> does this, I encounter that I cannot fit it properly into my code in
> access. Can someone help me with this piece of code?
>
> .
>
|