View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
Charles Williams Charles Williams is offline
external usenet poster
 
Posts: 968
Default using the same range name on different worksheets in a workbook

Hi Paul,

You can do this using Names that are scoped as Local to the worksheet:

Define names like Sheet1!Fred as =Sheet1!$A$4 and Sheet2!Fred as
=Sheet2!$B$77 etc

If you download Name manager from
http://www.decisionmodels.com/downloads.htm
it can simplify creating and managing these kind of names.

BTW although it is possible for a name to be both Local and Global I do not
recommend this as it is error-prone.


Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

"Paul" wrote in message
...
I'm writing VBA code that performs actions based on the names of cells in
a worksheet.

I'm building an application that has multiple worksheets in a workbook,
and I have written some VBA code in a general module that I would like to
be able to use in each of the worksheets.

Part of the code performs actions based on the Range names of certain
cells in the worksheet. Since I would like to be able to use this same
code to perform the same operations in the various worksheets, I would
like to be able to create the same Range name to corresponding cells in
each workbook, so the code will perform the same actions in each of the
worksheets. (I need to assign Range names because the "corresponding"
cells aren't always in the same Row).

However, I have noticed that if I try to use a Range name in one worksheet
that has already been defined in another worksheet, it won't let you do
it.

Is there any way I can give cells in two different worksheets the same
Range name, so the same VBA code can be used to perform the same
operations in the different worksheets?

Thanks in advance,

Paul