G
Guest
I have several complicated queries that I want to export to Excel. My
business never tends to do the things straightforward, and asks for all kinds
of crazy requests like the following (assume that a "portfolio" is a subset
of a "business"):
Sheet: Vendor Items
Header
Portfolio 1
Header
Portfolio 2
Header
Rollup of Business X (a series of portfolios on another sheet)
Header
Portfolio 3
Header
Grand Total of all of the above
....
It gets to be a nightmare, and it necessitates having to do code in VBA in
order to bring in the logic, since they are trying to get information rolled
up into the sheet with other data that is just individual portfolios. One
way that I've tried to tackle the issue in the past is to use all sorts of
union queries in order to get the data into one "final" query, export that to
excel and try to run a pre-made VBA macro I've made in Excel to format and
put all of the headers in place and what not.
It would be much easier if I could just do the following in VBA:
....
rs.movefirst
while rs.EOF = false
call WriteHeader
if rs.field("RollupType") = "Portfolio" then
call WritePortfolio(rs.fields("EntityName").value)
else
call WriteBusiness(rs.fields("EntityName").value)
end if
rs.movenext
wend
rs.close
set rs = nothing
However, this method tends to be slow, and I've tried any and all speed-up
tricks that I know of like naming things rs.fields(0).value and what not. It
seems that every time I am in Access and trying to send data to Excel in a
row-by-row fashion it is ungodly slow and could take upwards of an hour to
process production-level data by doing the DAO/ADO method, I have pinpointed
the bottleneck to not just moving from record to record, but also any OLE
Automation call to Excel, doing a call like "mysheet.Cells(y,x).Value = blah"
can take forever to run per call when you're looping even a few times through
information. Is there ANY method out there to speed up the interprocess
communication between Access and Excel in VBA?
business never tends to do the things straightforward, and asks for all kinds
of crazy requests like the following (assume that a "portfolio" is a subset
of a "business"):
Sheet: Vendor Items
Header
Portfolio 1
Header
Portfolio 2
Header
Rollup of Business X (a series of portfolios on another sheet)
Header
Portfolio 3
Header
Grand Total of all of the above
....
It gets to be a nightmare, and it necessitates having to do code in VBA in
order to bring in the logic, since they are trying to get information rolled
up into the sheet with other data that is just individual portfolios. One
way that I've tried to tackle the issue in the past is to use all sorts of
union queries in order to get the data into one "final" query, export that to
excel and try to run a pre-made VBA macro I've made in Excel to format and
put all of the headers in place and what not.
It would be much easier if I could just do the following in VBA:
....
rs.movefirst
while rs.EOF = false
call WriteHeader
if rs.field("RollupType") = "Portfolio" then
call WritePortfolio(rs.fields("EntityName").value)
else
call WriteBusiness(rs.fields("EntityName").value)
end if
rs.movenext
wend
rs.close
set rs = nothing
However, this method tends to be slow, and I've tried any and all speed-up
tricks that I know of like naming things rs.fields(0).value and what not. It
seems that every time I am in Access and trying to send data to Excel in a
row-by-row fashion it is ungodly slow and could take upwards of an hour to
process production-level data by doing the DAO/ADO method, I have pinpointed
the bottleneck to not just moving from record to record, but also any OLE
Automation call to Excel, doing a call like "mysheet.Cells(y,x).Value = blah"
can take forever to run per call when you're looping even a few times through
information. Is there ANY method out there to speed up the interprocess
communication between Access and Excel in VBA?