Thread: Naming Ranges
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Naming Ranges

This worked ok for me:

Option Explicit
Sub testme01()
Dim wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
With wks
.Names.Add Name:="stop1", RefersTo:=.Range("c7")
End With
Next wks
End Sub


The name was added to the worksheet's collection of names--not the workbook's
collection. It seemed easier to me.



James Montgomery wrote:

Hi,
I have used the recorder to Name a range and it gave me the following

ActiveWorkbook.Names.Add Name:="Stop1", RefersToR1C1:="=Sheet1!R7C3"

I really need to name the range R7C3 with "Stop1" on every sheet in the
Active Workbook and some of my workbooks vary in the number of sheets

Can someone help me?

Thank You


--

Dave Peterson