Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 8
Default Named ranges vs setting range in code

Hi all,

I have some code that needs to refer to ranges a fair bit and was
wondering if there are any differences speed wise between

(a) referring to named ranges ie.
x = range("Name")(j,i).value

and
(b)actually setting a range equal to a named range in the code ie.
set MyRange = range("Name")
x = myrange(j,i).value

is there even any difference at all between these two methods? I was
wondering if once set it would be faster to get values from MyRange
than to get them from range("Name"), if this is true there must be some
overhead in setting MyRange. So there must be a point after accessing
the range a number of times where setting MyRange becomes more
efficient.

I can test all this for myself but was just wondering if anybody could
give me some info first as to whether I would be wasting my time.

kind regards,

Tim

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Named ranges vs setting range in code

Tim,

I use range objects instead of named ranges whenever possible.

I just ran a test of 10,000 loops and the range object was about 9% faster.
Or you could say using the range name was about 10% slower...

Range name at .791 seconds
Range object at .719 seconds

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Tim" wrote in message
Hi all,
I have some code that needs to refer to ranges a fair bit and was
wondering if there are any differences speed wise between
(a) referring to named ranges ie.
x = range("Name")(j,i).value
and
(b)actually setting a range equal to a named range in the code ie.
set MyRange = range("Name")
x = myrange(j,i).value
is there even any difference at all between these two methods? I was
wondering if once set it would be faster to get values from MyRange
than to get them from range("Name"), if this is true there must be some
overhead in setting MyRange. So there must be a point after accessing
the range a number of times where setting MyRange becomes more
efficient.
I can test all this for myself but was just wondering if anybody could
give me some info first as to whether I would be wasting my time.
kind regards,
Tim

  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 8
Default Named ranges vs setting range in code

Thanks for taking the time to do that Jim,

The mystery is solved and the named ranges are gone.

Tim

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
Join non-contiguous ranges into one range via named range? ker_01 Excel Discussion (Misc queries) 3 May 1st 09 11:09 AM
Charting only Used Range with Named Ranges cooter24 Charts and Charting in Excel 3 January 27th 06 03:00 AM
setting a range using a named list in vba Gixxer_J_97[_2_] Excel Programming 12 March 12th 05 05:11 PM
Setting PrintArea by using Named Ranges Oren Klaber Excel Programming 2 January 30th 04 10:34 PM
Setting named range in VBA- how to set as formula/reference instead of text string? Keith R[_3_] Excel Programming 1 July 28th 03 10:26 PM


All times are GMT +1. The time now is 07:06 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"