how to see all named ranges

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
846
Office Version
  1. 2013
Platform
  1. Windows
I've come across the Name Manager function. It's pretty decent. However one doesn't get a visual of which areas of the workbook are named. Is there some way to get those parts of the workbook highlighted?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi bigdan,
Is there some way to get those parts of the workbook highlighted?
You mean besides clicking the down arrow at the left end of the formula bar and choosing one of the named ranges that displays?

Or... are you looking for some code that will list all the named ranges and their range addresses?

Does that help?
(Regular) Dan
 
Upvote 0
You mean besides clicking the down arrow at the left end of the formula bar and choosing one of the named ranges that displays?


lol!! that was easy! i had no idea about that one. that's not exactly what i was looking for but it'll solve the problem as well.

however in case this can be made more exact, i was looking for something that would highlight all the named ranges at the same time. can this be done? if not the given solution will work fine.

thanks dan!
 
Upvote 0
Save your workbook before running this!
Code:
[FONT=Fixedsys]Option Explicit[/FONT]
 
[FONT=Fixedsys]Public Sub HighlightNamedRanges()[/FONT]
 
[FONT=Fixedsys]  Dim oName As Name[/FONT]
[FONT=Fixedsys]  Dim mySheet As String[/FONT]
[FONT=Fixedsys]  Dim myRange As String[/FONT]
[FONT=Fixedsys]  Dim oCell As Range[/FONT]
 
[FONT=Fixedsys]  For Each oName In ThisWorkbook.Names[/FONT]
[FONT=Fixedsys]    If InStr(oName.RefersTo, "#REF!") = 0 Then[/FONT]
[FONT=Fixedsys]      mySheet = Mid(oName.RefersTo, 2, InStr(oName.RefersTo, "!") - 2)[/FONT]
[FONT=Fixedsys]      myRange = Mid(oName.RefersTo, InStr(oName.RefersTo, "!") + 1)[/FONT]
[FONT=Fixedsys]      Sheets(mySheet).Range(myRange).Interior.Color = vbYellow[/FONT]
[FONT=Fixedsys]    End If[/FONT]
[FONT=Fixedsys]  Next oName[/FONT]
 
[FONT=Fixedsys] MsgBox "WARNING: DON'T SAVE THIS WORKBOOK!" & Space(10), vbOKOnly + vbExclamation[/FONT]
 
[FONT=Fixedsys]End Sub[/FONT]
 
Upvote 0
Run it a second time with Interior.Color = xlNone to clear the highlighting. (This won't restore whatever colour was in there to start with, which is why I recommended saving the workbook first!)


You could add these lines immediately before the End If and the named ranges will then appear in a message box with the highlighting taking place as you click OK:-
Code:
[FONT=Fixedsys]      Sheets(mySheet).Activate
      MsgBox oName.Name & " " & oName.RefersTo
[/FONT]
 
Upvote 0
wow thanks a lot for this!

i dont actually know how to code yet so i wont be able to do this just yet. however that's next on my todo list so who knows, maybe even today.

so i take it since there was a need for this code excel doesnt have a built-in function for this. funny i think that'd be an imp thing. oh well.

thanks!
 
Upvote 0
Wouldn't oName.ReferstoRange be easier? ;)
 
Upvote 0
There are plenty of instructions on how to run VBA code but if ou get stuck, jst ask here and someone will respond.

There are all sprts of things which Excel won't do and VBA fills the gaps. There are also loads of things Excel will do but you decide you want them done slightly differently, so again VBA is called in to play.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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