View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Tushar Mehta Tushar Mehta is offline
external usenet poster
 
Posts: 1,071
Default Stripping Path from File String

Based on some code proposed by one of the newest MS MVPs, Colo...

10,000 loops consisting of 4 statements, each setting the same variable
to a different range:
Time Rank
Set r = Range("$A$1", "$A$1") 0.0901125 1
Set r = Range("A1", "A1") 0.1058 2
Set r = Cells(1, 1) 0.19815 5
Set r = Range("$A$1") 0.177712499 3
Set r = Range("A1") 0.180887499 4
Set r = [A1] 0.621437508 7
Set r = Cells(1, "A") 0.308837497 6

[The times are the average over 10 cycles and represent the time for
40,000 Set operations and one procedure call, since each test was in a
separate procedure.]

For me most of the results were a surprise.
Range(x,x) was faster than Range (x) by a factor of just under 50%
Cells(m,n) was slower than Range(x) by a bit
[x] was slower than Range(x) by a factor of 4
Cells(m,"x") was even possible, and slower than Cells(m,n) by 50%!

Of course, given that these are timings for 40,000 Set operations, it
won't convince me to stop using Cells() when appropriate to the task at
hand. And, since I never did develop the habit of using [x]... <g

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Thanks for the research. I usually use the while loop myself.

I figured there was overhead with evaluate - but didn't think as much as
with fileio - so you at least confirmed that. Still, it appears to be a
dog. That might be insightful for those that choose to use [A1] notation.
I played with that a while back and found it about 14 times slower than
Range("A1") type notation.