Create an Excel Named Range from Another Cell
Question details
The user wants to use text in a cell, such as a student's name, to create a named range in Excel.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains a label in one cell and data that the user wants to identify with that label as a defined name.
- Observed behavior
- A standard Excel formula cannot create or rename a defined name when the cell text changes.
Identify the cell containing the proposed name and the cells the name should refer to. Excel names must follow naming rules: they cannot contain spaces, start with a number, or look like cell references.
Use VBA to Create a Named Range from a Cell Value
Use a macro when you need Excel to read a cell's text and create a workbook-level name.
This example reads the name from A1 and makes it refer to B2:B10 on the active worksheet. Running the macro creates the name; it does not automatically rename it if A1 changes later.
Enter a valid, unused Excel name in A1 and place the data in B2:B10. Change these references in the macro if your worksheet uses different cells.
In desktop Excel, open Developer > Visual Basic, then choose Insert > Module.
Paste the following code into the module, return to the worksheet, and run CreateNameFromCell from Developer > Macros: Sub CreateNameFromCell() Dim ws As Worksheet Dim nm As String Dim ref As String Set ws = ActiveSheet nm = Trim$(CStr(ws.Range("A1").Value)) ref = "='" & Replace(ws.Name, "'", "''") & "'!$B$2:$B$10" ws.Parent.Names.Add Name:=nm, RefersTo:=ref End Sub
Open Formulas > Name Manager and confirm that the new name refers to the intended range. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if you want to keep the macro.

Create Named Ranges from Worksheet Labels
Use Create from Selection to make names from labels already next to your data without writing VBA.
Look Up the Student's Data Instead of Creating a Name
Use XLOOKUP when the goal is to retrieve a student's grade rather than create a separate defined name.
Create a Named Range in WPS Spreadsheet
Use WPS Spreadsheet to create a named range using a valid name copied from a worksheet cell. The name is created manually and does not automatically change when the cell value changes.
- 1. Open the workbook: Open your spreadsheet in WPS Spreadsheet and locate the cell containing the proposed name.
- 2. Copy a valid name: Copy the cell text and ensure it follows spreadsheet naming rules, with no spaces and no leading number.
- 3. Select the data: Select the cells you want the name to refer to, then choose Formulas > Define Name.
- 4. Define the range: Paste the name into the name field, check the range reference, and confirm to create the named range.

Frequently Asked Questions
Can an Excel formula create a defined name from a cell?
No. A formula can return or look up data, but it cannot create or rename a defined name. Use VBA or Formulas > Create from Selection instead.
Will a named range change when I edit its source label?
No. Editing the label does not automatically rename the defined name. Use Formulas > Name Manager to edit it, or run a suitably designed macro.
Why can't I use a student's full name as an Excel range name?
Defined names cannot contain spaces and must follow other naming rules. Use a valid name such as John_Doe, and check it in Formulas > Name Manager.
Do I need a separate named range for each student?
Not necessarily. If student names and grades are in corresponding columns, use a formula such as =XLOOKUP(D2,A2:A10,B2:B10) to return the grade for the name in D2.




