Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default renaming named ranges

Dear Experts:

I got a workbook with a lot of named ranges. They are named range1,
range2, range3, range4 .....range40.

Is it possible to ADD a ZERO before the SINGLE digit named ranges
(using VBA) so that they look like as follows: range01, range02, ...
range09 ... . Ranges named range10, range11 .... range40 etc. are to
be left untouched.

Help is much appreciated.

Thank you very much in advance.

Regards, Andreas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default renaming named ranges

Hi Andreas,

Am Mon, 4 Apr 2011 09:34:24 -0700 (PDT) schrieb AndreasHermle:

Is it possible to ADD a ZERO before the SINGLE digit named ranges
(using VBA) so that they look like as follows: range01, range02, ...
range09 ... . Ranges named range10, range11 .... range40 etc. are to
be left untouched.


Sub RangeNames()
Dim rngName As Name

For Each rngName In ThisWorkbook.Names
If Len(rngName.Name) = 6 Then
rngName.Name = Left(rngName.Name, 5) & _
Format(Right(rngName.Name, 1), "00")
End If
Next
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default renaming named ranges

I got a workbook with a lot of named ranges. They are named
range1, range2, range3, range4 .....range40.

Is it possible to ADD a ZERO before the SINGLE digit named
ranges (using VBA) so that they look like as follows: range01,
range02, ...range09 ... . Ranges named range10, range11 ....
range40 etc. are to be left untouched.


I would do it like this...

Sub FillOutRangeNames()
Dim N As Name
For Each N In ThisWorkbook.Names
If UCase(N.Name) Like "RANGE#" Then
N.Name = "Range" & Format(Right(N.Name, 1), "00")
End If
Next
End Sub

Rick Rothstein (MVP - Excel)
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default renaming named ranges

On Apr 4, 8:36*pm, Claus Busch wrote:
Hi Andreas,

Am Mon, 4 Apr 2011 09:34:24 -0700 (PDT) schrieb AndreasHermle:

Is it possible to ADD a ZERO before the SINGLE digit named ranges
(using VBA) so that they look like as follows: range01, range02, ...
range09 ... . Ranges named range10, range11 .... range40 etc. are to
be left untouched.


Sub RangeNames()
Dim rngName As Name

For Each rngName In ThisWorkbook.Names
* * If Len(rngName.Name) = 6 Then
* * * * rngName.Name = Left(rngName.Name, 5) & _
* * * * * * *Format(Right(rngName.Name, 1), "00")
* * End If
Next
End Sub

Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


Hi Claus,

great, works like a charm. Thank you very much for your great and
professional support. Regards, Andreas
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default renaming named ranges

On Apr 4, 8:53*pm, "Rick Rothstein"
wrote:
I got a workbook *with a *lot of named ranges. They are named
range1, range2, range3, range4 .....range40.


Is it possible to ADD a ZERO before the SINGLE digit named
ranges (using VBA) so that they look like as follows: range01,
range02, ...range09 ... . Ranges named range10, range11 ....
range40 etc. are to be left untouched.


I would do it like this...

Sub FillOutRangeNames()
* Dim N As Name
* For Each N In ThisWorkbook.Names
* * If UCase(N.Name) Like "RANGE#" Then
* * * N.Name = "Range" & Format(Right(N.Name, 1), "00")
* * End If
* Next
End Sub

Rick Rothstein (MVP - Excel)


Hi Rick,

as always, your codes work just fine. I really appreciate your
professional support.

Thank you very much.

Regards, Andreas
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
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
Excel {2007} Named Ranges: Renaming, Deleting etc... DemonTraitor Excel Discussion (Misc queries) 4 November 27th 07 12:06 PM
renaming a named range Steve Excel Discussion (Misc queries) 2 March 23rd 07 08:29 AM
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
Systematically Renaming Ranges MWS Excel Programming 3 February 16th 06 03:11 PM


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