Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Adding a Name range with vba

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,118
Default Adding a Name range with vba

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." wrote in message
...
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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Adding a Name range with vba

On 3 Feb, 00:12, "Jan T." 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
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
Adding a Range Joey041 Excel Worksheet Functions 1 November 21st 06 09:23 AM
Adding to a Row Range VicWestVan Excel Programming 4 August 17th 06 09:53 PM
Adding named range gives error "method range of object _Global failed " Gunnar Johansson Excel Programming 3 August 10th 04 01:54 PM
adding reference-to-range control to excel range Nir Sfez Excel Programming 1 March 2nd 04 06:11 PM
sheets.range and adding cells that are out of the range Phillips Excel Programming 1 November 18th 03 09:27 PM


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