Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA for changing a defined name reference

Sorry if this has been asked before, but is it possible and if so ho
can it be done to change the reference through VBA of a defined name
for instance, I have a list called 'People' and it resides on one of m
worksheets at $a10:$a60 and I want to be able to change the th
reference to say $a10:$a59 if I wanted to decrease the reference of th
list by one cell or alterantely if I wanted to increase by one cell t
$a10:$a61 if I wanted to increase the list size.

Thanks in advance

Henr

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default VBA for changing a defined name reference

try this
ActiveWorkbook.Names.Add Name:="People", RefersTo:="=sheet2!$A$10:$a$61"
but you would be better off if you used a defined name
=offset($a$10,0,0,counta($A:$A)+5,1)
you would need to modify the +5 to suit your needs. Test by using f5 goto
people.
--
Don Guillett
SalesAid Software

"Roy Miller " wrote in message
...
Sorry if this has been asked before, but is it possible and if so how
can it be done to change the reference through VBA of a defined name,
for instance, I have a list called 'People' and it resides on one of my
worksheets at $a10:$a60 and I want to be able to change the the
reference to say $a10:$a59 if I wanted to decrease the reference of the
list by one cell or alterantely if I wanted to increase by one cell to
$a10:$a61 if I wanted to increase the list size.

Thanks in advance

Henri


---
Message posted from
http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA for changing a defined name reference

Dim rng as Range
set rng = Range("People")
rng.resize(rng.rows.count-1).Name = "People"

or to increase

Dim rng as Range
set rng = Range("People")
rng.Resize(rng.rows.count+1).Name = "People"

--
Regards,
Tom Ogilvy

"Roy Miller " wrote in message
...
Sorry if this has been asked before, but is it possible and if so how
can it be done to change the reference through VBA of a defined name,
for instance, I have a list called 'People' and it resides on one of my
worksheets at $a10:$a60 and I want to be able to change the the
reference to say $a10:$a59 if I wanted to decrease the reference of the
list by one cell or alterantely if I wanted to increase by one cell to
$a10:$a61 if I wanted to increase the list size.

Thanks in advance

Henri


---
Message posted from http://www.ExcelForum.com/



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
Changing Defined Names Lelethu Excel Worksheet Functions 2 March 18th 10 09:43 AM
Need to use the reference in a defined name in adifference colum [email protected] Excel Discussion (Misc queries) 5 January 29th 08 05:04 PM
Changing a Defined Name Dan Beard[_2_] Excel Discussion (Misc queries) 4 December 3rd 07 12:19 PM
Updating cells which reference a defined name Mike Miller Excel Discussion (Misc queries) 1 November 9th 06 01:06 AM
Changing Multiple Defined Names At Once? Wuddus Excel Discussion (Misc queries) 3 September 26th 06 12:57 AM


All times are GMT +1. The time now is 08:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"