ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Which runs faster (https://www.excelbanter.com/excel-programming/392707-runs-faster.html)

Barb Reinhardt

Which runs faster
 
Sheet1.Cells(1,1) = Sheet2.Cells(1,1)
Sheet1.Cells(1,1).value = Sheet2.Cells(1,1).value

Or something else?

Thanks,
Barb Reinhardt

Mike H

Which runs faster
 
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

"Barb Reinhardt" wrote:

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

Or something else?

Thanks,
Barb Reinhardt


Tom Ogilvy

Which runs faster
 
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.

--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote:

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

Or something else?

Thanks,
Barb Reinhardt


Jim Cone

Which runs faster
 

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"
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


Jon Peltier

Which runs faster
 
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
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Barb Reinhardt" wrote in message
...
Sheet1.Cells(1,1) = Sheet2.Cells(1,1)
Sheet1.Cells(1,1).value = Sheet2.Cells(1,1).value

Or something else?

Thanks,
Barb Reinhardt





All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com