Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Automating creation of named ranges???

Hi Folks,

I'm have 52 sheets named 1,2,3,etc., that I want to create named ranges on
in the following fashion...

sheet 1 (named "1") has A:C named w1s
sheet 1 (named "1") has D:F named w1c

sheet 2 (named "2") has A:C named w2s
sheet 2 (named "2") has D:F named w2c

.... all the way down the line.

Is there a simple way to slap together a one-time use macro so I don't have
t odo this all manually?

Thanks in Advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 373
Default Automating creation of named ranges???

How about this? James

Sub NameEm()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Activate
Columns("A:C").Name = "w" & ws.Name & "s"
Columns("D:F").Name = "w" & ws.Name & "c"
Next ws
End Sub

"Stephen" wrote in message
...
Hi Folks,

I'm have 52 sheets named 1,2,3,etc., that I want to create named ranges on
in the following fashion...

sheet 1 (named "1") has A:C named w1s
sheet 1 (named "1") has D:F named w1c

sheet 2 (named "2") has A:C named w2s
sheet 2 (named "2") has D:F named w2c

... all the way down the line.

Is there a simple way to slap together a one-time use macro so I don't
have
t odo this all manually?

Thanks in Advance!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Automating creation of named ranges???

Sub Namer()
Dim b As Boolean
Dim ws As Worksheet
Dim nms As Names
Set nms = ActiveWorkbook.Names
For Each ws In ActiveWorkbook.Worksheets
With ws
b = False
On Error Resume Next
b = Val(.Name) = .Name
On Error GoTo 0
If b Then
nms.Add "w" & .Name & "s", .Range("A:C")
nms.Add "w" & .Name & "c", .Range("D:F")
End If
End With
Next

End Sub

If you were to use Worksheet level names, also known as Local names, each
sheet could have identically named Names, eg "ws" & "wc"

Regards,
Peter T
"Stephen" wrote in message
...
Hi Folks,

I'm have 52 sheets named 1,2,3,etc., that I want to create named ranges on
in the following fashion...

sheet 1 (named "1") has A:C named w1s
sheet 1 (named "1") has D:F named w1c

sheet 2 (named "2") has A:C named w2s
sheet 2 (named "2") has D:F named w2c

... all the way down the line.

Is there a simple way to slap together a one-time use macro so I don't

have
t odo this all manually?

Thanks in Advance!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Automating creation of named ranges???

Sub nameranges()
For sheetcount = 1 To 52
refername = "=" & Chr(39) & "names " & sheetcount & Chr(39) & "!A:C"
ActiveWorkbook.Names.Add Name:="w" & sheetcount & "s", _
RefersTo:=refername
refername = "=" & Chr(39) & "names " & sheetcount & Chr(39) & "!D:F"
ActiveWorkbook.Names.Add Name:="w" & sheetcount & "c", _
RefersTo:=refername
Next sheetcount
End Sub

"Stephen" wrote:

Hi Folks,

I'm have 52 sheets named 1,2,3,etc., that I want to create named ranges on
in the following fashion...

sheet 1 (named "1") has A:C named w1s
sheet 1 (named "1") has D:F named w1c

sheet 2 (named "2") has A:C named w2s
sheet 2 (named "2") has D:F named w2c

... all the way down the line.

Is there a simple way to slap together a one-time use macro so I don't have
t odo this all manually?

Thanks in Advance!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Automating creation of named ranges???

that's sweet!

thanks a bunch!

"Peter T" wrote:

Sub Namer()
Dim b As Boolean
Dim ws As Worksheet
Dim nms As Names
Set nms = ActiveWorkbook.Names
For Each ws In ActiveWorkbook.Worksheets
With ws
b = False
On Error Resume Next
b = Val(.Name) = .Name
On Error GoTo 0
If b Then
nms.Add "w" & .Name & "s", .Range("A:C")
nms.Add "w" & .Name & "c", .Range("D:F")
End If
End With
Next

End Sub

If you were to use Worksheet level names, also known as Local names, each
sheet could have identically named Names, eg "ws" & "wc"

Regards,
Peter T
"Stephen" wrote in message
...
Hi Folks,

I'm have 52 sheets named 1,2,3,etc., that I want to create named ranges on
in the following fashion...

sheet 1 (named "1") has A:C named w1s
sheet 1 (named "1") has D:F named w1c

sheet 2 (named "2") has A:C named w2s
sheet 2 (named "2") has D:F named w2c

... all the way down the line.

Is there a simple way to slap together a one-time use macro so I don't

have
t odo this all manually?

Thanks in Advance!




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
Automating the Creation of Userforms in VBA Noel[_2_] Excel Programming 4 October 15th 07 03:35 PM
Help with automating creation of Pie Chart(s) MP Charts and Charting in Excel 1 September 28th 06 11:42 PM
Mass Creation of Named Ranges? [email protected] Excel Programming 13 July 12th 06 08:59 AM
Mass Creation of Named Ranges? [email protected] Excel Discussion (Misc queries) 7 July 11th 06 08:41 AM
Automating hyperlink creation Steve Williams Excel Worksheet Functions 1 October 14th 05 01:50 AM


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