View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Creating Named Ranges with VBA


Sorry, I always create local names like this, to the names collection of the workbook:

ActiveWorkbook.Names.Add Name:="Sheet1!Test2", RefersToR1C1:="=Sheet1!R6C2"

So, to create a global name using your syntax, instead of adding the name to the
Worksheets(sht).Names collection, use

ActiveWorkbook.Names.Add Name:=rangename, RefersTo:="=" & seriesrange

HTH,
Bernie
MS Excel MVP


"Barb Reinhardt" wrote in message
...
I don't think I made myself clear. I believe that there are range names
that are global within the workbook and range names that only work on the
current worksheet.

This example:

Worksheets(sht).Names.Add Name:=rangename, RefersTo:="=" & seriesrange

Created a named range that was only available on sht.

How would I create a named range using VBA that's available on all sheets.
If you could provide the syntax, I'd appreciate it.

Thanks,
Barb

"Bernie Deitrick" wrote:

What would change if the range name was not tied to the worksheet, but
global for the wookbook?


rangename would not have the sheetname as part of the string.

HTH,
Bernie
MS Excel MVP


"Barb Reinhardt" wrote in message
...
I have programmatically created a named range that is tied to a worksheet
using the following

Worksheets(sht).Names.Add Name:=rangename, RefersTo:="=" & seriesrange

What would change if the range name was not tied to the worksheet, but
global for the wookbook?

Thanks,
Barb Reinhardt