Name Cells???

buzz71023

Active Member
Joined
May 29, 2011
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
Does anyone know if it is possible to have two cells/Ranges named the same thing in one Workbook (Two different Sheets)? If so how might I accomplish that.

I want Cell "D1" on Sheet1 to be named "Test"
and Cell "T17" on Sheet2 to be named "Test" as well.

this doesn't have to be done in VBA, I will just help reduce several of my codes if I can get them named the same thing.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hello
That's possible. When creating the named range (for instance, Ctrl-F3), indicate that you want a sheet level named range. (As opposed to the default Workbook-level named range).

Hence, you choose a name on a smaller scope.
 
Upvote 0
In the Define Name-->New dialog there's a Scope selection where you can limit a named range to a specific worksheet.

HTH,
 
Upvote 0
Never mind I think I figured it out... If there is a way to do in in VBA I wouldnt mind knowing that for future ref.
 
Upvote 0
If there is a way to do in in VBA I wouldnt mind knowing that for future ref.

Just record a macro. ;) You'll see the difference in the recorded code between setting a named range with workbook scope vs. worksheet.
 
Upvote 0
Never mind I think I figured it out... If there is a way to do in in VBA I wouldnt mind knowing that for future ref.

For named ranges with a global (workbook) scope, the VBA command is:

Code:
ActiveWorkbook.Names.Add Name:="...", RefersToR1C1:="..."

For named ranges with a local (worksheet) scope, the VBA command is similar but you add the worksheet name:

Code:
ActiveWorkbook.Worksheets("Sheet1").Names.Add Name:="...", RefersToR1C1:="..."

Of course, ActiveWorkbook or worksheet references could be different. As long as you have valid workbook and/or worksheet references, you can add a member to the resp. Names collection.
 
Upvote 0
yeah I was going to just record the macro but the codes are usually much longer than someone with experience.
 
Upvote 0

Forum statistics

Threads
1,216,102
Messages
6,128,852
Members
449,471
Latest member
lachbee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top