View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
AndreasHermle AndreasHermle is offline
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