How to highlight all named ranges in Excel?
For some purpose, in Excel, we may always create some range names for a range of cells. Sometimes, we want to know where the named ranges are in the whole workbook and highlight them. The simplest way for us is to click the range names from the Name Box to select the range and fill color to it. But, if there are lots of named ranges in the workbook, this method will be time-consuming. How could we highlight all of the named ranges in Excel at once?
Recommended Excel Productivity Tools
Here is a code to highlight all the named ranges in a workbook, you can do as this:
1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Highlight all named ranges in Excel
Sub HighlightRange() 'Update 20140317 Dim xName As Name Dim Rng As Range On Error Resume Next For Each xName In Application.ActiveWorkbook.Names Set Rng = xName.RefersToRange Rng.Interior.ColorIndex = 6 Next End Sub
3. Then press F5 key to execute this code, and all the named ranges have been highlighted with yellow color in the whole workbook.
1. If you want to fill the named ranges with other colors, you just need to change the ColorIndex = 6 as you like.
2. After applying this code, all the original color in the named ranges are canceled and covered by this new color.
Recommended Productivity Tools for Excel