PC Review


Reply
Thread Tools Rate Thread

Adding a Name range with vba

 
 
Jan T.
Guest
Posts: n/a
 
      2nd Feb 2008
Hi. I have successfully made Dynamic Name Ranges through the Excel
Insert/Name menu. In the Refers To text box I would write something
like:
=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),1)

I tried vba code like:
Activeworksheet.Names.Add ...... and so on.

However, when I try to write code in vba to do this, it fails.
How should I write the code without the ReferTo part to fail?

Thanks a lot for any help!

Regards
Jan



 
Reply With Quote
 
 
 
 
Ron Coderre
Guest
Posts: n/a
 
      2nd Feb 2008
Try this:

ActiveWorkbook.Names.Add _
Name:="MyDynRng", _
RefersTo:="=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),1)"

Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)

"Jan T." <(E-Mail Removed)> wrote in message
news:ec1002da-d453-4dbb-9402-(E-Mail Removed)...
> Hi. I have successfully made Dynamic Name Ranges through the Excel
> Insert/Name menu. In the Refers To text box I would write something
> like:
> =OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),1)
>
> I tried vba code like:
> Activeworksheet.Names.Add ...... and so on.
>
> However, when I try to write code in vba to do this, it fails.
> How should I write the code without the ReferTo part to fail?
>
> Thanks a lot for any help!
>
> Regards
> Jan
>
>
>



 
Reply With Quote
 
Jan T.
Guest
Posts: n/a
 
      3rd Feb 2008
On 3 Feb, 00:12, "Jan T." <Jan.Thorsten...@hotmail.com> wrote:
> Hi. I have successfully made Dynamic Name Ranges through the Excel
> Insert/Name menu. In the Refers To text box I would write something
> like:
> =OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),1)
>
> I tried vba code like:
> Activeworksheet.Names.Add ...... and so on.
>
> However, when I try to write code in vba to do this, it fails.
> How should I write the code without the ReferTo part to fail?
>
> Thanks a lot for any help!
>
> Regards
> Jan


Thank you so much. That was excactly what I needed!

Regards
Jan
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a range to a range? serdar Microsoft Excel Discussion 1 23rd Nov 2005 05:25 PM
Adding named range gives error "method range of object _Global failed " Gunnar Johansson Microsoft Excel Programming 3 10th Aug 2004 01:54 PM
adding reference-to-range control to excel range Nir Sfez Microsoft Excel Programming 1 2nd Mar 2004 06:11 PM
Adding one to a range =?Utf-8?B?RG91ZyBW?= Microsoft Excel Misc 7 2nd Feb 2004 05:04 PM
sheets.range and adding cells that are out of the range Phillips Microsoft Excel Programming 1 18th Nov 2003 09:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:52 AM.