Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programatically increase the size of all named ranges

Hi,

I have about 25+ named ranges in my excel workbook. All of these ranges
currently end at row 250 and I want to increase this to 1500 for all
ranges. How do I do this programatically?

Any help is deeply appreciated.

Thanks,
Ashwin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Programatically increase the size of all named ranges

Sub IncreaseRanges()
Dim nme As Name
Dim rng As Range

For Each nme In ActiveWorkbook.Names
On Error Resume Next
Set rng = Range(nme.RefersTo)
On Error GoTo 0
If Not rng Is Nothing Then
Set rng = rng.Resize(150 - rng.Row + 1)
ActiveWorkbook.Names.Add Name:=nme.Name, RefersTo:=rng.Address(,
, , True)
Set rng = Nothing
End If
Next nme
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
Hi,

I have about 25+ named ranges in my excel workbook. All of these ranges
currently end at row 250 and I want to increase this to 1500 for all
ranges. How do I do this programatically?

Any help is deeply appreciated.

Thanks,
Ashwin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Programatically increase the size of all named ranges

Assuming they are all workbook level names and you want to change them all:
Sub ResizeNames()
Dim nm as Name, rng as Range
for each nm in ActiveWorkbook.names
set rng = nm.RefersToRange
set rng = rng.Resize(250)
rng.Name = nm.name
Next
End Sub

Test this on a copy of your workbook to guard against unsuspected results.

--
Regards,
Tom Ogilvy


" wrote:

Hi,

I have about 25+ named ranges in my excel workbook. All of these ranges
currently end at row 250 and I want to increase this to 1500 for all
ranges. How do I do this programatically?

Any help is deeply appreciated.

Thanks,
Ashwin


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Programatically increase the size of all named ranges

Ashwin,

Back it up before trying this:

Sub test()
Dim nam As Name
Dim new_range As Range

For Each nam In ActiveSheet.Names
'in case the name doesn't refer to a range
On Error Resume Next
nam.RefersTo = "=" &
nam.RefersToRange.Resize(nam.RefersToRange.Cells.C ount + 1250).Address
On Error GoTo 0
Next nam
End Sub

hth,

Doug

wrote in message
ups.com...
Hi,

I have about 25+ named ranges in my excel workbook. All of these ranges
currently end at row 250 and I want to increase this to 1500 for all
ranges. How do I do this programatically?

Any help is deeply appreciated.

Thanks,
Ashwin



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Programatically increase the size of all named ranges

Ashwin,

This assumed that they are all worksheet level names, which is probably not
true. For workbook level names change "ActiveSheet.Names" to
"ActiveWorkbook.Names". Or run it with both if you have a mix.

hth,

Doug Glancy

"Doug Glancy" wrote in message
...
Ashwin,

Back it up before trying this:

Sub test()
Dim nam As Name
Dim new_range As Range

For Each nam In ActiveSheet.Names
'in case the name doesn't refer to a range
On Error Resume Next
nam.RefersTo = "=" &
nam.RefersToRange.Resize(nam.RefersToRange.Cells.C ount + 1250).Address
On Error GoTo 0
Next nam
End Sub

hth,

Doug

wrote in message
ups.com...
Hi,

I have about 25+ named ranges in my excel workbook. All of these ranges
currently end at row 250 and I want to increase this to 1500 for all
ranges. How do I do this programatically?

Any help is deeply appreciated.

Thanks,
Ashwin







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programatically increase the size of all named ranges

Thanks all for your replies.

Doug - I tried your solution and it works. The first name that it picks
up is the entire worksheet itself even though there is no range defined
like that. After I skip that this the program works.

Thanks,
Ashwin

Doug Glancy wrote:
Ashwin,

This assumed that they are all worksheet level names, which is probably not
true. For workbook level names change "ActiveSheet.Names" to
"ActiveWorkbook.Names". Or run it with both if you have a mix.

hth,

Doug Glancy

"Doug Glancy" wrote in message
...
Ashwin,

Back it up before trying this:

Sub test()
Dim nam As Name
Dim new_range As Range

For Each nam In ActiveSheet.Names
'in case the name doesn't refer to a range
On Error Resume Next
nam.RefersTo = "=" &
nam.RefersToRange.Resize(nam.RefersToRange.Cells.C ount + 1250).Address
On Error GoTo 0
Next nam
End Sub

hth,

Doug

wrote in message
ups.com...
Hi,

I have about 25+ named ranges in my excel workbook. All of these ranges
currently end at row 250 and I want to increase this to 1500 for all
ranges. How do I do this programatically?

Any help is deeply appreciated.

Thanks,
Ashwin




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
Number in cell increase with increase in font size. Value increases with increase in font.[_2_] Excel Discussion (Misc queries) 2 August 9th 07 01:58 PM
Copy data in named ranges to a newer version of the same template to identical ranges handstand Excel Programming 0 August 21st 06 03:51 PM
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM
Automatically increase Named Ranges Gerrym Excel Discussion (Misc queries) 4 January 4th 05 01:49 PM
Programatically nameing ranges Adam Ward Excel Programming 4 May 12th 04 09:43 PM


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