Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
WHY the same macro runs so slowly on a different but faster comput Jerry Excel Discussion (Misc queries) 2 August 15th 07 10:30 PM
can this be done faster? Frank Excel Discussion (Misc queries) 7 August 9th 07 10:02 PM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Can faster CPU+larger/faster RAM significantly speed up recalulati jmk_li Excel Discussion (Misc queries) 2 September 28th 05 10:24 AM


All times are GMT +1. The time now is 04:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"