# Named Ranges and External References

> Define workbook and worksheet names with NamedRangeCollection, write relative, absolute and sheet references and bind external workbooks for formulas.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Spreadsheet Documents > Named Ranges and External References
- **1576 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/named-ranges/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/named-ranges/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/spreadsheets/named-ranges/llms-full.txt

---

A name such as `TaxRate` or `NetAmounts` gives business meaning to a range or a constant, so that your formulas rely less on hardcoded addresses. A name belongs either to the workbook or to one worksheet, and names of the two kinds have a different lookup scope. References to other worksheets and to external workbooks follow rules of their own, which the sections below describe.

### Define Names in Code

The following code defines a workbook name for a tax rate and a worksheet name for a column of net amounts, then uses both in a formula. `editor` is the [Spreadsheet](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/llms-full.txt) of the browser editor, created as in [JavaScript](https://docs.textcontrol.com/tx-sheet-control/getting-started/spreadsheet-editor/javascript/llms-full.txt):

```javascript
const book = editor.workbook;
const sheet = book.sheets.at(0);
book.names.set('TaxRate', '=0.19');
sheet.names.set('NetAmounts', "='Sales'!$F$2:$F$25");
sheet.cell('H2').setFormula('=SUM(NetAmounts)*TaxRate');
```

The code works as follows:

- [Spreadsheet.workbook](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/spreadsheet/workbook-property/llms-full.txt) returns the workbook, and [Workbook.sheets](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbook/sheets-property/llms-full.txt) with [SheetCollection.at](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/sheetcollection/at-method/llms-full.txt) returns its first worksheet.
- [Workbook.names](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbook/names-property/llms-full.txt) returns the [NamedRangeCollection](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/namedrangecollection/llms-full.txt) of the workbook scope. Its [set](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/namedrangecollection/set-method/llms-full.txt) method creates or replaces a definition: `TaxRate` refers to the constant `0.19`.
- [Worksheet.names](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/worksheet/names-property/llms-full.txt) returns the collection of the worksheet scope. `NetAmounts` refers to the absolute range `$F$2:$F$25` of the worksheet `Sales`.
- [Worksheet.cell](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/worksheet/cell-method/llms-full.txt) and [Cell.setFormula](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/cell/setformula-method/llms-full.txt) write a formula into `H2` that uses both names instead of addresses.

### Manage Names in the Editor

Open **Formulas > Name Manager** to review names across the workbook, including names scoped to other worksheets. Selecting a row leaves the worksheet selection unchanged. The list shows each name's calculated value, reference, scope and comment; long entries have tooltips with their full text.

![Name Manager listing defined names and a table with their values, references, scope and comments](https://docs.textcontrol.com/assets/img/tx-sheet-control/name-manager-list.dd8ca5be.webp)

Use **Search Names** to find text in names, references, scopes or comments. The filter beside the command buttons narrows the list to worksheet names, workbook names, names with or without errors, defined names or table names. **All Names** clears the filter. Hidden name definitions are not listed.

- **New…** opens a settings dialog where you enter a name, choose Workbook or a worksheet as its scope, supply a reference or formula and add an optional comment.
- **Edit…**, or a double-click on a row, opens the selected definition. Its scope stays fixed. Select **OK** to apply the edit or **Cancel** to discard the draft.
- **Delete** removes the selected defined name. Table names cannot be deleted here; manage the table on the worksheet.

![Edit Name with a Definition section, fixed workbook scope, reference formula and comment field](https://docs.textcontrol.com/assets/img/tx-sheet-control/name-manager-edit.a2beb4e1.webp)

To change only a definition's reference, edit **Refers To** below the list and select **Apply Reference** or press Enter. **Revert** discards that draft; Escape also reverts a changed reference. The range-picker button lets you select cells on a worksheet without changing the definition until you apply the reference. Selecting another name or closing with **Close** applies a pending reference edit; invalid edits remain visible for correction.

Table names appear with Workbook scope. Select **Edit…** to rename a table through the existing table operation, which also updates structured references. A table's reference is read-only in Name Manager: use **Resize Table** to change its range.

Name Manager keeps its header, toolbar and **Close** action in a fixed frame while the name list scrolls. In a narrow viewport, wider table columns scroll horizontally within the list. **New Name** and **Edit Name** use the same dialog elements with one **Definition** section and aligned fields; no separate preview is needed because Name Manager already lists calculated values.

Use the arrow keys, Home and End to select rows. Enter or F2 opens the selected name for editing, and Delete removes a selected defined name. Applied changes take effect immediately and can be undone after you close Name Manager. Closing the New Name or Edit Name dialog without confirming leaves its draft unapplied.

### How Names Are Resolved

- **Case.** Name matching is case-insensitive.
- **Scope.** In the scope of a worksheet, a local worksheet name takes precedence over a workbook name that is equal to it.
- **Valid names.** Use valid names that cannot be confused with cell references.
- **Renaming.** Avoid renaming a template field without updating its consumers.

### Write References

Relative references adjust with supported fill and copy operations. Absolute references retain the selected row or column. In formula text, quote sheet names that contain spaces and escape apostrophes. Use explicit worksheet handles when an operation must not depend on the active sheet.

Range handles accept supported rectangles, or names that resolve to them. Formula unions or intersections and three-dimensional references are calculation expressions, and not necessarily valid rectangle handles.

### Bind External Workbooks

External references require explicitly supplied documents or compatible imported cached values. Configure external workbooks through the calculation API: [Workbook.calculation](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbook/calculation-property/llms-full.txt) returns the [WorkbookCalculation](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/llms-full.txt), whose [setExternalWorkbook](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/workbookcalculation/setexternalworkbook-method/llms-full.txt) binds a snapshot of an already loaded workbook under a name. Supply the correct named workbook, and refresh it deliberately when the source data changes.

> Important
>
> **File Names in Formulas.** Do not assume that a file name inside a formula grants permission to read an application file or a network URL.

Unbound references can report `#REF!`. Review the results before export. When a live external workbook is unnecessary, keep business-critical rates as known typed data.

### What the File Keeps

Name definitions and supported native references participate in file persistence. Application callbacks and provider registrations remain application configuration.

### Next Steps

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt): use names, sheet-qualified references and structured references in formulas.
- [Lifetime and Concurrency](https://docs.textcontrol.com/tx-sheet-control/document-processing/lifetime/llms-full.txt): manage the owners of documents, their handles, backend jobs and concurrency.

---

## Nearby

- **Previous:** [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)
- **Next:** [Dates and Locales](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/dates/llms-full.txt)
