Fastest way of getting data into excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Everyone

I am writing an app at the moment which has to import a large amount of data (1m + cells) into excel and am currently using the excel object model to do this. I am using the cells value property to do this i.e 'objsheet.Cells(1,1).value = x'

I have noticed that usings the cell object model seem to be very slow is there a faster way of getting the data into excel

Cheers.....Ji
 
Hi
one way:
disable screenupdating and automatic calculation at the
beginning of your macro and enable it again after
inserting your values
-----Original Message-----
Hi Everyone,

I am writing an app at the moment which has to import a
large amount of data (1m + cells) into excel and am
currently using the excel object model to do this. I am
using the cells value property to do this
i.e 'objsheet.Cells(1,1).value = x'.
I have noticed that usings the cell object model seem to
be very slow is there a faster way of getting the data
into excel?
 
put your data into an array and transfer the array to a range

dim varr(65536,256) as variant
'
' fill array with data
'
objsheet.range("a1:IV65536")=varr

Usually it pays to transfer the information in as large a block as possible


Charles
______________________
Decision Models
FastExcel Version 2 now available.
www.DecisionModels.com/FxlV2WhatsNew.htm

jnc said:
Hi Everyone,

I am writing an app at the moment which has to import a large amount of
data (1m + cells) into excel and am currently using the excel object model
to do this. I am using the cells value property to do this i.e
'objsheet.Cells(1,1).value = x'.
I have noticed that usings the cell object model seem to be very slow is
there a faster way of getting the data into excel?
 
You could create a temporary array in VBA and fill it. Then transfer
the array to a range in one statement:
DataRange.Value=TempArray
This is much faster than inserting into individual cells. Also see
Frank K's tips.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top