close

Hi,

Can someone tell me what the pros and cons are (if any) of these 2 ways
of naming a range.

ActiveWorkbook.Names.Add NAME:=quot;HOMEquot;, RefersTo:=ActiveCell
Range(quot;HOMEquot;).Select

or

Dim HOME As Range
Set HOME = ActiveCell
HOME.Select

Thanks,

DaveUIt seems to me that the first method creates a named range that is
essentially meaningless to the user and is only used for VBA processing.
Additionally, if you don't write code to delete the named range it will just
sit there in the workbook waiting for somebody to ask what it means.

The second alternative is a cleaner way to declare the range variable
without having it intrude upon the user-facing part of the workbook.

Just my opinion....Your mileage may vary.

***********
Regards,
Ron

XL2002, WinXP-Proquot;Davequot; wrote:

gt; Hi,
gt;
gt; Can someone tell me what the pros and cons are (if any) of these 2 ways
gt; of naming a range.
gt;
gt; ActiveWorkbook.Names.Add NAME:=quot;HOMEquot;, RefersTo:=ActiveCell
gt; Range(quot;HOMEquot;).Select
gt;
gt; or
gt;
gt; Dim HOME As Range
gt; Set HOME = ActiveCell
gt; HOME.Select
gt;
gt; Thanks,
gt;
gt; DaveU
gt;
gt;

Ron, that's a good explanation. I did have a vague idea that the 2nd
way was better (the code seemed quot;neaterquot;) but couldn't quite say why it
was so.

Thanks a lot

DaveU

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()