In this article, I will tell you how to define a named constant and a named range in excel and then reference them in excel formulas. In this way, you can make your excel formula more readable, and easier to maintain.
1. How To Define Named Constant To Reference Excel Cell.
1.1 How To Define Excel Named Constant.
- Open the excel worksheet, and click the Formulas tab.
- Then click the Define Name item in the Defined Names group.
- It will pop up a New Name dialog window.
- Input the constant name ( for example Discount ) in the Name text box.
- Select the constant scope from the Scope drop-down list, then the named constant can be used either in the whole workbook or selected worksheet.
- Input the number value 0.8 in the text box Refers to, then the named constant’s value will be 0.8 when you use it later.
- You can also input a formula such as =sheet1!$A$1 in the Refers to text box so that the constant’s value can be changed when the cell A1‘s value is changed in the worksheet sheet1.
1.2 How To Use The Defined Excel Named Constant In Formula.
- After you defined the named constant, you can use it in your excel formula like below.
- You can reference the named constant in your formula directly like =Discount*100, or =Discount*A1.
- You can also click the Formulas tab —> Defined Names group —> Use in Formula item to select the existing names to use when you input a formula.
2. How To Create Excel Named Range.
2.1 How To Create Excel Named Range Steps.
- Suppose there are the below data in the cells of column A.
A 1 Score 2 100 3 90 4 80 5 100 6 90
- If we want to give the above cell region A2:A6 a name, then we can follow the below steps.
- Select the cell region A2:A6.
- Click the Formulas tab —>Define Name item in the Defined Names group.
- Input the name value ( such as Scores) in the Name text box.
- Select the named range scope from the Scope drop-down list.
- Then the named range object can be used in the whole Workbook wide or in a single worksheet that you select from the Scope list.
- Click the OK button to create the named range object.
2.2 How To Use The Named Range Object In Excel.
- Now you can use the above range name to reference the cell range in the excel formula.
- For example, you can use the formula =SUM(Scores) to calculate the summary number value of the cell’s value in the range.
- You can also use the formula =AVERAGE(Scores) to calculate the average number value of the cell’s value in the range.
2.3 How To Create Named Range Based On Row Or Column Labels.
- If the excel data contains labels on the top row, bottom row, left column, or right column, then you can quickly create the named range object based on those labels.
- Below is an example of excel cell region data.
WorkHour SleepHour Workday 8 8 Weekend 2 9
- In the above data cells, the row labels are Workday and Weekend, and the column labels are WorkHour and SleepHour.
- Select all the above cells including the labels row and column.
- Click the Formulas tab —> Defined Names group —> Create from Selection item.
- Select the checkbox Top row and Left column in the pop-up Create Names from Selection dialog window.
- Because the data label are located on the data cells’ top row and left column, so we select the above 2 checkboxes.
- Click the OK button, then it will create 4 named range objects with the name of the labels.
3. How To Manage Existing Named Object In Excel.
- Click the Formulas tab —> Name Manager item in the Defined Names group, then it will open the Name Manager dialog window.
- It will list all the existing names in the dialog, you can see the name objects that use the row or column labels as the name.
- you can click the New button to create a new name.
- Click the Edit button to edit one existing name.
- Click the Delete button to delete an existing name.