Names (a/k/a “Defined Names”, “Named Ranges”, etc.) A Name is what Excel calls a variable that resides in a worksheet or a workbook. Names are often assigned to cells or ranges; for example, you might place a sales tax rate into a cell and name the cell SalesTax, and subsequently use the cell’s name rather than its address in a formula.
-->
Ranges are easier to identify by name than by A1 notation. To name a selected range, click the name box at the left end of the formula bar, type a name, and then press ENTER.
Note There are two types of named ranges: Workbook Named Range and WorkSHEET Specific Named Range.
Workbook Named Range
A Workbook Named Range references a specific range from anywhere in the workbook (it applies globally).
How to Create a Workbook Named Range:
Excel Range Names In Formulas
As explained above, it is usually created entering the name into the name box to the left end of the formula bar. Note that no spaces are allowed in the name.
WorkSHEET Specific Named Range
A WorkSHEET Specific Named Range refers to a range in a specific worksheet, and it is not global to all worksheets within a workbook. You can refer to this named range by just the name in the same worksheet, but from another worksheet you must use the worksheet name including '!' the name of the range (example: the range 'Name' '=Sheet1!Name').
The benefit is that you can use VBA code to generate new sheets with the same names for the same ranges within those sheets without getting an error saying that the name is already taken.
How to Create a WorkSHEET Specific Named Range:
Example, of WorkSHEET Specific Named Range: Selected range to name are A1:A10
Chosen name of range is 'name' within the same worksheet refer to the named name mere by entering the following in a cell '=name', from a different worksheet refer to the worksheet specific range by included the worksheet name in a cell '=Sheet1!name'.
Referring to a Named Range
The following example refers to the range named 'MyRange' in the workbook named 'MyBook.xls.'
The following example refers to the worksheet-specific range named 'Sheet1!Sales' in the workbook named 'Report.xls.'
Set Print Range Names In Excel
To select a named range, use the GoTo method, which activates the workbook and the worksheet and then selects the range.
The following example shows how the same procedure would be written for the active workbook.
Sample code provided by: Dennis Wallentin, VSTO & .NET & Excel
This example uses a named range as the formula for data validation. This example requires the validation data to be on Sheet 2 in the range A2:A100. This validation data is used to validate data entered on Sheet 1 in the range D2:D10.
Looping Through Cells in a Named Range
The following example loops through each cell in a named range by using a For Each...Next loop. If the value of any cell in the range exceeds the value of
Limit , the cell color is changed to yellow.
About the ContributorHow To Create A Named Range In Excel Mac
Dennis Wallentin is the author of VSTO & .NET & Excel, a blog that focuses on .NET Framework solutions for Excel and Excel Services. Dennis has been developing Excel solutions for over 20 years and is also the coauthor of 'Professional Excel Development: The Definitive Guide to Developing Applications Using Microsoft Excel, VBA and .NET (2nd Edition).'
Support and feedbackName Range In Excel Mac
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |