Which runs faster

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

Guest

Sheet1.Cells(1,1) = Sheet2.Cells(1,1)
Sheet1.Cells(1,1).value = Sheet2.Cells(1,1).value

Or something else?

Thanks,
Barb Reinhardt
 
Sheet1.Cells(1,1) = Sheet2.Cells(1,1) = 37 seconds in a 1 to 50k loop
Sheet1.Cells(1,1).value = Sheet2.Cells(1,1).value = 43 seconds in a 1 to 50k
loop


Now who's going to tell us why?

Mike
 
Actually, I found copy Pastespecial Values to be significantly faster. It
may have been unique to that case, but using the below method was taking
forever.
 
Why...
Fewer dots = Faster code
However, omitting the default property of an object instead of specifying it
is not good coding practice.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Mike H" <[email protected]>
wrote in message
Sheet1.Cells(1,1) = Sheet2.Cells(1,1) = 37 seconds in a 1 to 50k loop
Sheet1.Cells(1,1).value = Sheet2.Cells(1,1).value = 43 seconds in a 1 to 50k
loop
Now who's going to tell us why?
Mike
 
You might also want to compare

Sheet1.Cells(1, 1)

with

Sheet1.Range("A1")

Also, if you are looping through a range, the above in a loop will be far
slower than doing the entire range in one go, e.g.,

Sheet1.Range("A1:Z25").Value = Sheet2.Range("A1:Z25").Value

- Jon
 

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