Exporting to existing Excel workbook (1 Viewer)

tmyers

Well-known member
Local time
Today, 16:29
Joined
Sep 8, 2020
Messages
1,090
I have been trying to research this, and while I have found various methods to move data from Access into Excel using TransferSpreadSheet, how can I control the range in which the data gets inserted?
I have a template that has a header and named columns further down and such, so I would need to control what row/column that data would be inserted at. Could someone provide a quick example that I could look at to get an idea?
 

Isaac

Lifelong Learner
Local time
Today, 13:29
Joined
Mar 14, 2017
Messages
8,774
Glad you found something that seems to be sufficient. I've had very good results with CopyFromRecordset.
Once it's done I just loop through the DAO Fields of the recordset to handle the headers.

Code:
dim fld as dao.field, rng as object
set rng=yourworksheetvariable.range("A1")

for each fld in yourrecordsetobject.fields
     rng.value=fld.name
     set rng=rng.offset(0,1)
next fld
 

Users who are viewing this thread

Top Bottom