Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Excel spreadsheet

Status
Not open for further replies.

Anesthaesia

Technical User
Aug 30, 2001
126
0
0
GB
Hi All,

I need to populate an Excel spreadsheet with a large amount of data. Everything is working fine, but it takes ages to write the entries.

As the data needs to be a in a specific order its going into an array and then to Excel using "oSheet.Cells(nRow, nCol).Value = strData"

Is there any way to speed this up? It takes about 2sec to write one row (32 columns) and there will be about 800 rows, which means over 20 minutes to do a single sheet.

Any suggestions on how to deal with this would be great (VB6 & Excel 2003)
 
Pass it the recordset and have it load from there automatically.

"If I were to wake up with my head sewn to the carpet, I wouldn't be more surprised than I am right now.
 




Check out the CopyFromRecordset method.

"As the data needs to be a in a specific order its going into "

You realize that you can sort in Excel if required.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
After doing a bit of searching it seems this is known issue and the best way to do it is dropping an array straight into a worksheet.

My VBA knowledge is limited so if anyone could give me an example of doing this I am sure it is what I am after.

Thanks to those that replied, but neither of these are options.
 




How are you loading the array?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 




I mean, from what source?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
As Skip says, what source?

Take a look at this link if you are loading from Access or another database as it uses ADO to write the records to Excel. You will find it quick and you would not have to mess with Excel Automation and you could sort the records in your SQL statement on retrieval.

thread222-1452603

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top