Changing the scope of a named range

KentKHI

Active Member
Joined
Oct 1, 2004
Messages
492
I have a workbook that has recently changed on me and is causing a lot of grief. I have a lot of named ranges that the scope of the named range has changed to a new sheet. This is creating a lot of problems! Is there any way to manually change the scope of a named range? without deleting the nmaed range and recreating it?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
On your toolbar, select FORMULAS, then NAME MANAGER, then select the name of the range that's giving you trouble. You will see in the formulas box its logistics. Type in the corrected info...careful not to use your arrow keys or it will take control of the formula and write in the movement of the arrow key. Press the ENTER key when finished. it will then ask if you want to save the changes. Of course...YES.
 
Upvote 0
On your toolbar, select FORMULAS, then NAME MANAGER, then select the name of the range that's giving you trouble. You will see in the formulas box its logistics. Type in the corrected info...careful not to use your arrow keys or it will take control of the formula and write in the movement of the arrow key. Press the ENTER key when finished. it will then ask if you want to save the changes. Of course...YES.

Thanks for your quick response and effort to help me! I do appreciate it.

I am not sure I explained myself well enough. I am talking about the "scope" of the named range, and not the name of the sheet where the named range is located.

When I double click to open up an editing box to edit the named range, there is a small drop down box titled "Scope". It is grayed out and I am not able to change the Scope because of it. The range location is fine, but the scope is wrong so it is creating a problem for me.
 
Upvote 0
I found out after doing some googling that Excel can't handle this, and that a free program from FastExcel has been made to enable you to change the scope of a named range. That was a lifesaver for me!
 
Upvote 0
I just had the same problem... "Shift3Home" was scoped to the sheet "Shift 3" and I needed it scoped to the whole workbook, so here's how I solved it:
First, I went to the "Shift 3" sheet. This sheet had "Shift3Home" as a name, but as mentioned the scope was limited. So I put the cursor in that range as defined.
Next, Name Manager and selected "Define Name." When the dialogue box came up I made certain that the Scope I wanted was selected, and that the range was indeed the same as the original range.
Then I just typed in the exact same name, fully expecting to see "name already in use." But, Voila! It took the same name and changed the scope.
Problem solved.

Hope this helps someone... Oh yeah, Excel 2007 is what I have here at work.

Regards,
XLXRider
 
Upvote 0
I just had the same problem... "Shift3Home" was scoped to the sheet "Shift 3" and I needed it scoped to the whole workbook, so here's how I solved it:
First, I went to the "Shift 3" sheet. This sheet had "Shift3Home" as a name, but as mentioned the scope was limited. So I put the cursor in that range as defined.
Next, Name Manager and selected "Define Name." When the dialogue box came up I made certain that the Scope I wanted was selected, and that the range was indeed the same as the original range.
Then I just typed in the exact same name, fully expecting to see "name already in use." But, Voila! It took the same name and changed the scope.
Problem solved.

Hope this helps someone... Oh yeah, Excel 2007 is what I have here at work.

Regards,
XLXRider

Why yes indeed it did thanks
 
Upvote 0
I just came here in the course of investigating the feasibility of changing the scope of a set of named ranges from Workbook scope to Worksheet scope. Having found that it works, I suspected that I knew why. As the following report shows, the reason that this is possible is that the trick creates a duplicate name that has worksheet scope.

Since the worksheet scoped name trumps the identical workbook scoped name when the worksheet to which it is scoped is active, it hides the workbook scoped name. On closer inspection, you will see that the worksheet scoped name is prefixed with the name of the sheet, followed by an exclamation point. It is this prefix that enables the Names collection, which is a subsidiary of the Workbook object, to store worksheet scoped names for copies of worksheets in its key-value collection. In programming terms, the Names collection is implemented as a Dictionary object.

Name 1 of 35: Name = _xlfn.CONCAT, Address = =#NAME?, Scope = Workbook
Name 2 of 35: Name = _xlfn.IFERROR, Address = =#NAME?, Scope = Workbook
Name 3 of 35: Name = Sheet2!achPlainText, Address = =Sheet2!$F$16, Scope = Worksheet
Name 4 of 35: Name = achPlainText, Address = =Sheet2!$F$16, Scope = Workbook
Name 5 of 35: Name = Ciphertext_length, Address = =Sheet2!$F$36, Scope = Workbook
Name 6 of 35: Name = Sheet1!CreateEncryptedMessage_EBP, Address = =Sheet1!$C$2, Scope = Worksheet
Name 7 of 35: Name = CreateEncryptedMessage_EBP, Address = ='Memory Map'!$E$7, Scope = Workbook
Name 8 of 35: Name = Sheet1!CreateEncryptedMessage_Offse_to_intPlaintextLen, Address = =Sheet1!$C$3, Scope = Worksheet
Name 9 of 35: Name = Sheet1!ebp_4018h_as_Seen_from_Main_Routine, Address = =Sheet1!$C$8, Scope = Worksheet
Name 10 of 35: Name = Sheet1!ebp_4018h_computed, Address = =Sheet1!$C$4, Scope = Worksheet
Name 11 of 35: Name = Sheet1!ebp_4018h_per_CodeView, Address = =Sheet1!$C$5, Scope = Worksheet
Name 12 of 35: Name = Sheet2!intPlainTextLength, Address = =Sheet2!$F$59, Scope = Worksheet
Name 13 of 35: Name = intPlainTextLength, Address = =Sheet2!$F$59, Scope = Workbook
Name 14 of 35: Name = Sheet2!lpMainEBP, Address = =Sheet2!$F$57, Scope = Worksheet
Name 15 of 35: Name = lpMainEBP, Address = =Sheet2!$F$57, Scope = Workbook
Name 16 of 35: Name = lpSubEBP, Address = =Sheet2!$F$14, Scope = Workbook
Name 17 of 35: Name = lpszPlainText, Address = =Sheet2!$F$60, Scope = Workbook
Name 18 of 35: Name = MAIN_OFFSET_TO_PLAINTEXT, Address = =Sheet2!$F$52, Scope = Workbook
Name 19 of 35: Name = MAIN_OFFSET_TO_PLAINTEXT_LENGTH, Address = =Sheet2!$F$49, Scope = Workbook
Name 20 of 35: Name = Sheet1!Main_routine_EBP, Address = =Sheet1!$C$6, Scope = Worksheet
Name 21 of 35: Name = Sheet1!Main_routine_EBP_less_CreateEncryptedMessage_EBP, Address = =Sheet1!$C$7, Scope = Worksheet
Name 22 of 35: Name = Sheet2!Message_1, Address = =Sheet2!$F$18, Scope = Worksheet
Name 23 of 35: Name = Message_1, Address = =Sheet2!$F$18, Scope = Workbook
Name 24 of 35: Name = Sheet2!Message_2, Address = =Sheet2!$F$19, Scope = Worksheet
Name 25 of 35: Name = Message_2, Address = =Sheet2!$F$19, Scope = Workbook
Name 26 of 35: Name = Offset_of_thief_s_EBP_to_callee_s_EBP, Address = ='Memory Map'!$E$5, Scope = Workbook
Name 27 of 35: Name = Offset_of_thief_s_ESP_to_callee_s_EBP, Address = ='Memory Map'!$E$4, Scope = Workbook
Name 28 of 35: Name = Sheet2!OFFSET_TO_FUNCTION_EBP, Address = =Sheet2!$F$55, Scope = Worksheet
Name 29 of 35: Name = OFFSET_TO_FUNCTION_EBP, Address = =Sheet2!$F$55, Scope = Workbook
Name 30 of 35: Name = Plaintext_length, Address = =Sheet2!$F$35, Scope = Workbook
Name 31 of 35: Name = Reference, Address = ='Location Usage per Disassembly'!$D$1, Scope = Workbook
Name 32 of 35: Name = Sheet2!SUB_OFFSET_TO_PLAINTEXT, Address = =Sheet2!$F$53, Scope = Worksheet
Name 33 of 35: Name = SUB_OFFSET_TO_PLAINTEXT, Address = =Sheet2!$F$53, Scope = Workbook
Name 34 of 35: Name = Sheet2!SUB_OFFSET_TO_PLAINTEXT_LENGTH, Address = =Sheet2!$F$50, Scope = Worksheet
Name 35 of 35: Name = SUB_OFFSET_TO_PLAINTEXT_LENGTH, Address = =Sheet2!$F$50, Scope = Workbook

Following is the VBA macro and private function that generated the report shown above.

Option Explicit
Public Sub EnumerateNamedRanges()
Dim lngOrd As Long: lngOrd = 0
Dim lngAll As Long: lngAll = ActiveWorkbook.Names.Count
Dim rn As Name

For Each rn In ActiveWorkbook.Names
lngOrd = lngOrd + 1
Debug.Print "Name " & lngOrd & " of " & lngAll & ": Name = " & rn.Name _
& ", Address = " & rn.RefersTo _
& ", Scope = " & RangeScopeShow(rn)
Next ' For Each rn In ActiveWorkbook.Names
EnumerateNamedRanges_End:
MsgBox "EnumerateNamedRanges Done!", _
vbExclamation, _
ActiveWorkbook.FullName
Exit Sub
EnumerateNamedRanges_Err:
MsgBox "Error encountered in subroutine EnumerateNamedRanges: " & Err.Description & " (Error # " & Err.Number, _
vbExclamation, _
ActiveWorkbook.FullName
Err.Clear
Resume EnumerateNamedRanges_End
End Sub ' EnumerateNamedRanges

Private Function RangeScopeShow(ByRef prn As Name) As String
If TypeOf prn.Parent Is Worksheet Then
RangeScopeShow = "Worksheet"
Else
RangeScopeShow = "Workbook"
End If ' If TypeOf prn.Parent Is Worksheet Then
End Function ' RangeScopeShow


The above code could easily be simplified by folding function
RangeScopeShow into the macro.
<strike></strike>


<strike></strike>
 
Upvote 0
Following is the simplified macro described in my previous message.

Code:
Option Explicit
'   Posted bu me in "Changing the Scope of a Named Range"
'   at https://www.mrexcel.com/forum/excel-questions/456002-changing-scope-named-range.html
Public Sub EnumerateNamedRanges()
    Dim lngOrd As Long: lngOrd = 0
    Dim lngAll As Long: lngAll = ActiveWorkbook.Names.Count
    Dim rn As Name
    
    For Each rn In ActiveWorkbook.Names
        lngOrd = lngOrd + 1
        
        If TypeOf rn.Parent Is Worksheet Then
            Debug.Print "Name " & lngOrd & " of " & lngAll & ": Name = " & rn.Name _
                        & ", Address = " & rn.RefersTo _
                        & ", Scope = Worksheet"
        Else
            Debug.Print "Name " & lngOrd & " of " & lngAll & ": Name = " & rn.Name _
                        & ", Address = " & rn.RefersTo _
                        & ", Scope = Workbook"
        End If  ' If TypeOf rn.Parent Is Worksheet Then
    Next    ' For Each rn In ActiveWorkbook.Names
EnumerateNamedRanges_End:
    MsgBox "EnumerateNamedRanges Done!", _
           vbExclamation, _
           ActiveWorkbook.FullName
    Exit Sub
EnumerateNamedRanges_Err:
    MsgBox "Error encountered in subroutine EnumerateNamedRanges: " & Err.Description & " (Error # " & Err.Number, _
           vbExclamation, _
           ActiveWorkbook.FullName
    Err.Clear
    Resume EnumerateNamedRanges_End
End Sub ' EnumerateNamedRanges

The above macro is tested, and the test showed that it produces exactly the same result as does the VBA that generated the report shown in the previous message.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,847
Members
449,051
Latest member
excelquestion515

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