Tying a Named Range to a Value Instead of a Cell

Written by Allen Wyatt (last updated April 26, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


1

In his data, Larry has a named range that refers to cell C7. If he sorts the data, the value that was in cell C7 is now in cell C15. Larry would like the named range, after the sort, to refer to cell C15, but it still refers to cell C7. He wonders if there is a way to make a named range refer to the value in a cell (so it travels with the value) rather than to the cell itself.

No, there is no way to do this in Excel. When a name refers to a range (thus, a "named range"), then it always refers to that range, even after sorting. The range hasn't change, after all—just the values within the range have changed.

There are ways around this, however. The key is to remember that Excel allows the naming of more things than just cell ranges. Names can refer to ranges, values, or formulas. It is telling that Larry is using a named range to refer to a single cell, not a multi-cell range. Since Larry wants to always refer to the value that is originally within cell C7, he can use a name to refer to the value instead of to the cell containing the value.

Let's say that cell C7 contains a static value, such as 5 or 23 or 123.45 or "apple" or "blue." In that case, you can simply assign the value to a name, in the following manner:

  1. Display the Formulas tab of the ribbon.
  2. Click the Define Name tool in the Defined Names group. Excel displays the New Name dialog box. (See Figure 1.)
  3. Figure 1. The New Name dialog box.

  4. In the Name box, enter a descriptive name, such as MyValue. (Note that there can be no spaces in the name.)
  5. In the Refers To box, enter the value, such as 5 or 23 or 123.45 or "apple" or "blue."
  6. Click OK to add the name and close the dialog box.

Now you can use the name anywhere in the worksheet that you want. For instance, let's say that in step 4 you entered the value 23. With the name defined, you could use the following formula anywhere you want to get the result of 37:

=MyValue + 14

If you later need to change the value associated with the MyValue name, then you can use the Name Manager (within the Defined Names group of the Formulas tab of the ribbon) to modify the value. Of course, if you are doing that, and especially if you need to modify the value often, then it makes sense to rethink the logic of your worksheet. In that case, it would make sense to define a static data entry area. Then, you can refer to the cells in that data entry area in your main data. Sort the main data, and the data entry area is not affected. This approach bypasses using named ranges (or named values) completely.

If you want to stick with names, remember that they can also be associated with formulas. For instance, Larry indicated that the value he wants to always have associated with the named range is in column C. (Larry says it starts out at cell C7.) Further, let's assume that the value within cell C7 is 123. Using the steps already defined above, in step 4, place the following into the Refers To box:

=INDEX($C:$C,MATCH(123,$C:$C, 0))

Now whatever name you created (for instance, MyValue) will return the value 123, provided the value appears in column C. If the value is not in the column, then MyValue returns #N/A. Since sorting simply reorders the values within column C, then the value that started at cell C7 (123) can now be at a different location (perhaps cell C15), but the MyValue name will always return 123 because the value is still within column C.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10252) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Printing without Opening

Want to print one ore more workbooks without the need of actually opening the file? It's easy to do when you rely on ...

Discover More

Keeping Table Rows Together

When you create a table that extends beyond a single page, you may want to make sure that the information in a table row ...

Discover More

Deleting Blank Columns

Import data from another program, and you could end up with a lot of blank columns in your data. Here's the quickest way ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2019 For Dummies today!

More ExcelTips (ribbon)

Shortcut to Move between Two Worksheets

Moving between to adjacent worksheets is easy; Excel provides a shortcut key to do the trick. If you want to move between ...

Discover More

Drop-Down List Font Sizes

Excel has several features that cannot be customized. The font size in the drop-down lists is one of them. If you need ...

Discover More

Selecting a Suggestion with the Keyboard

Excel tries to anticipate what you want to type into a cell, particularly when it comes to entering formulas. Here are ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 3?

2025-04-28 14:51:49

J. Woolley

I believe this issue arises only when sorting a range of cells that have constant values. If one of those cells is tagged with a comment, that comment will stay with its cell while the cell's value is sorted; therefore, the comment can be used to locate the cell and its value.
My Excel Toolbox includes the following function to return the first cell on a worksheet that has a legacy unthreaded comment (Note) with text containing a specified Substring:
    =CellByComment(Substring, [CaseSensitive], [SheetRef])
If optional CaseSensitive is FALSE (default), alphabetic case of Substring is ignored; otherwise, comparison of Substring with each comment's text will be case-sensitive. If optional SheetRef is omitted, comments on the cell formula's worksheet will be searched for Substring. To find a cell on a different worksheet, SheetRef must be a cell or range on that sheet. If no cell is found, the function returns #REF! (Error 2023).
Here are some examples:
=CellByComment("Tag #1") -- returns the value of a cell with "Tag #1" in its comment's text
=CellByComment("JW", TRUE) -- returns the value of a cell with "JW" in its comment's case-sensitive text
=CellByComment("my cell", , [Book1.xlsx]Sheet1!$A$1) -- returns the value of a cell on Sheet1 of Book1.xlsx with "my cell" in its comment's text
=CELL("address", CellByComment("local") -- returns the address of a cell with "local" in its comment's text
Here's an abbreviated version:

Function CellByComment(Substring As String) As Variant
    Dim item As Comment
    For Each item In Application.Caller.Worksheet.Comments
        If InStr(item.Shape.TextFrame.Characters.Text, Substring) > 0 Then
            Set CellByComment = item.Parent
            Exit Function
        End If
    Next item
    CellByComment = CVErr(xlErrRef)
End Function

See https://sites.google.com/view/MyExcelToolbox/


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.