Excel 2010 with Oracle as my DB.
I have this data in a recordset (recSet) coming from my DB that may look like:
[pre]
AMT
5 201206 $32,436.80
5 201207 $28,227.00
5 201208 $242.50
6 201204 $33.22
7 201204 $36.04
7 201205 $16,199.00
7 201206 $363,427.45
7 201207 $34,015.24
7 201208 $3,364,965.85[/pre]
And I put it into Excel that looks like this
[pre]
Z AA AB AC AD
201204 201205 201206 201207 201208
Apr-12 May-12 Jun-12 Jul-12 Aug-12
5 $32,436.80 $28,227.00 $242.50
6 $33.22
7 $36.04 $16,199.00 $363,427.45 $34,015.24 $3,364,965.85
8 $8,212.19 $142,881.46 $391,247.88 $374,317.21
9
10
11 $1,649.00 $77,315.08
[/pre]
I have some other information in columns A-Y, but this part takes the most of time to populate.
I read the data record by record from my recordset, match date from my record (YYYYMM, like 201206) with the cell in row 1 that has the same value (201206) and populate Excel one cell at the time with the code like this:
[tt]
Cells(intCFr, intS).Value = recSet!AMT.Value[/tt]
(where intCFr and intS are variables to point to the right cell )
Dates in cells in row 1 depend on dates seleted by user.
Since I have to deal with about 1000-2000 records for the time span of 5 years (5 years x 12 months = 60 columns in Excel) that takes time to populate.
Is there any faster way to do it?
Most of the time I use:
[tt]Range(“A1515”).Value = Array(...)[/tt]
to populate whole row of cells in one line of code, which is a lot faster, although my preferred way is to use
[tt]Range("A2").CopyFromRecordset recMyRst[/tt]
which is the best/fastest.
Have fun.
---- Andy
I have this data in a recordset (recSet) coming from my DB that may look like:
[pre]
AMT
5 201206 $32,436.80
5 201207 $28,227.00
5 201208 $242.50
6 201204 $33.22
7 201204 $36.04
7 201205 $16,199.00
7 201206 $363,427.45
7 201207 $34,015.24
7 201208 $3,364,965.85[/pre]
And I put it into Excel that looks like this
[pre]
Z AA AB AC AD
201204 201205 201206 201207 201208
Apr-12 May-12 Jun-12 Jul-12 Aug-12
5 $32,436.80 $28,227.00 $242.50
6 $33.22
7 $36.04 $16,199.00 $363,427.45 $34,015.24 $3,364,965.85
8 $8,212.19 $142,881.46 $391,247.88 $374,317.21
9
10
11 $1,649.00 $77,315.08
[/pre]
I have some other information in columns A-Y, but this part takes the most of time to populate.
I read the data record by record from my recordset, match date from my record (YYYYMM, like 201206) with the cell in row 1 that has the same value (201206) and populate Excel one cell at the time with the code like this:
[tt]
Cells(intCFr, intS).Value = recSet!AMT.Value[/tt]
(where intCFr and intS are variables to point to the right cell )
Dates in cells in row 1 depend on dates seleted by user.
Since I have to deal with about 1000-2000 records for the time span of 5 years (5 years x 12 months = 60 columns in Excel) that takes time to populate.
Is there any faster way to do it?
Most of the time I use:
[tt]Range(“A1515”).Value = Array(...)[/tt]
to populate whole row of cells in one line of code, which is a lot faster, although my preferred way is to use
[tt]Range("A2").CopyFromRecordset recMyRst[/tt]
which is the best/fastest.
Have fun.
---- Andy