{
  "category": "Information functions",
  "display_name": "SHEET",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.SHEET",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 5 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 5 recorded answers",
    "workbook_corpus": {
      "cells": 5,
      "matched": 5
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/host_facts.rs#L449-L449"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/host_facts::first_cell",
        "catalogue/host_facts::cell_value",
        "catalogue/host_facts::column_letters",
        "catalogue/host_facts::facts",
        "catalogue/host_facts::qualified_sheet",
        "catalogue/host_facts::cell",
        "catalogue/host_facts::s_number",
        "catalogue/host_facts::info",
        "catalogue/host_facts::sheet",
        "format/cell_info::sections",
        "format/cell_info::tokens",
        "format/cell_info::is_date_time",
        "format/cell_info::date_time_class",
        "format/cell_info::places",
        "format/cell_info::number_class",
        "format/cell_info::classify",
        "ported/a1_refs::split_prefix",
        "ported/a1_refs::parse_cell_token",
        "ported/a1_refs::parse_column_token",
        "ported/a1_refs::parse_row_token",
        "ported/a1_refs::parse_a1_reference",
        "ported/address::address_name_character",
        "ported/address::address_name_is_reference",
        "ported/address::quote_sheet_text_if_needed"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/host_facts.rs#L449-L449",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 5 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.SHEET.json",
  "name": "SHEET",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n- **`SHEETS([reference])`** is the count to `SHEET`'s index: how many sheets, rather than which\n  one. They share an implementation module and a documentation lineage, both arrived in Excel\n  2013, and they are routinely confused. `SHEET` returns a position; `SHEETS` returns a\n  cardinality.\n- **`CELL(\"filename\", ref)`** is the traditional pre-2013 route to a sheet's *name*, extracted\n  from the returned path with `MID` and `FIND`. `SHEET` gives a number, not a name, so it does\n  not replace that idiom — there is still no clean built-in \"what is this sheet called\".\n- **`INFO(\"numfile\")`** counts worksheets across *all open workbooks*, which is a third and\n  different quantity.\n- **`ROW` and `COLUMN`** are the within-sheet coordinates; `SHEET` is the third axis.\n- **`ISREF` and `INDIRECT`** are the usual companions when a sheet name is being assembled from\n  text and needs validating first.\n\n\n",
    "how-to-implement": "\n### Notes for implementers\n\n\n1. **The count includes every sheet type.** An implementation that enumerates only visible\n   worksheets will be off by the number of hidden and chart sheets to the left of the target —\n   a silent, data-dependent error.\n2. **Two argument forms, two error results.** Reference-not-valid is `#REF!`; name-not-found is\n   `#N/A`. Route them separately.\n3. **The omitted form needs the calling cell's sheet from the execution context**, not from an\n   argument. It is a caller-aware call and must be declared as one.\n4. **The reference must survive preparation unresolved**, or the sheet identity is lost before\n   the function runs.\n5. **Decide the 3-D, multi-area and external-reference cases explicitly**, and record them as\n   decisions awaiting evidence. The documentation covers none of them.\n\n\n",
    "quirks": "\n### Result and edge cases\n\n\nReturns a `Number` — a 1-based tab position.\n\n- **Hidden, very hidden, chart, macro and dialog sheets all count**, per the documented remark.\n  This is the most consequential edge case and it is documented rather than inferred.\n- **The number is positional and unstable** under tab reordering, insertion and deletion.\n- **A 3-D reference** (`Sheet1:Sheet3!A1`) spans several sheets. What `SHEET` returns for one is\n  not addressed by the documentation and is not established here — the first sheet of the span\n  is the plausible answer, and plausible is not measured.\n- **An external-workbook reference** — a reference into another file — raises the question of\n  *whose* tab order is being counted. Not addressed by the documentation, not established here.\n- **A multi-area reference** (`(Sheet1!A1, Sheet2!A1)`) spans two sheets. Not addressed, not\n  established.\n- **`SHEET` is not available in the object model.** Microsoft says so explicitly: \"SHEET is not\n  available in the Object Model (OM) because the Object Model already includes similar\n  functionality.\" Automation code should read `Worksheet.Index` rather than evaluating this\n  function.\n\n\n\n### Errors\n\n\nBoth documented, and the pair is worth memorising because they encode the two argument forms:\n\n- **`#REF!`** — \"If the value argument is not a valid reference, SHEET returns the #REF! error.\"\n- **`#N/A`** — \"If the value argument is not a valid sheet name, SHEET returns the #NA error\n  value.\" (Microsoft's page writes it `#NA`; the worksheet value is `#N/A`.)\n\nSo a broken *reference* gives `#REF!` while an unknown *name* gives `#N/A` — the lookup-style\nerror for the lookup-style argument. An implementation that collapses the two loses real\ninformation.\n\nArity failure (two or more arguments) is expected to be refused at formula entry rather than\nevaluated ([the call pipeline](../model/03-call-pipeline.md)).\n\n\n",
    "sources": "- Microsoft, \"SHEET function\" —\n  <https://support.microsoft.com/en-us/office/sheet-function-44718b6f-8b87-47a1-a9d6-b701c06cff24>.\n  Read for this page: the description, the syntax, the `value` argument description verbatim,\n  the counting remark naming visible/hidden/very-hidden worksheets and macro/chart/dialog\n  sheets, both documented error conditions, and the object-model note.\n- Handbook, [the execution context](../model/04-execution-context.md) — the calling cell and the\n  workbook state a host query reads.\n- Handbook, [the value universe](../model/01-value-universe.md) — three-dimensional and\n  multi-area reference shapes.\n\n\n",
    "version-differences": "No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.",
    "what-it-does": "\n`SHEET([value])` returns the **position number** of a sheet within the workbook.\n\nMicrosoft's description: \"The SHEET function returns the sheet number of the specified sheet or\nother reference.\" Called with no argument, it returns the number of the sheet containing the\nformula.\n\nThe number is a **tab-order index**, not an identity. It counts sheets from the left of the tab\nstrip, and Microsoft states the counting rule with unusual completeness: \"SHEET\nlocating/identification capability includes all worksheets (visible, hidden, or very hidden) in\naddition to all other sheet types (macro, chart, or dialog sheets).\"\n\nThat sentence is the function. Two consequences follow, and both are the reason `SHEET` results\nshould be treated with care:\n\n1. **Hidden and very-hidden sheets are counted.** A workbook that shows three tabs may return `5`\n   for the third one. The number does not match what a user can see.\n2. **Chart sheets, macro sheets and dialog sheets are counted.** These are not worksheets and do\n   not appear in most sheet enumerations, but they occupy positions.\n\nAnd because it is positional, **the number is not stable**: dragging a tab, inserting a sheet, or\ndeleting one renumbers everything to its right. `SHEET` answers \"where is this sheet right now\",\nnever \"which sheet is this\".\n\n\n### Arguments\n\n\n`value` — **optional**, at most one. The published signature is `SHEET([reference])`; Microsoft's\npage writes it as `SHEET(value)` and describes the argument as \"the name of a sheet or a\nreference for which you want to obtain the sheet number\".\n\nThe argument therefore has two admissible forms, and they take different paths:\n\n| Form | Example | What it means |\n|---|---|---|\n| A reference | `SHEET(Sheet3!A1)` | The sheet the reference lives on |\n| A sheet name as text | `SHEET(\"Sheet3\")` | The sheet with that name |\n| Omitted | `SHEET()` | The sheet containing the formula |\n\nThe text form is the one that surprises people: `SHEET` accepts a *name*, which most\nreference-aware functions do not. That is why the two failure modes are different errors — an\ninvalid reference and an unknown name are distinct conditions with distinct results, documented\nseparately.\n\nThe omitted form is a **caller-aware** call ([the call pipeline](../model/03-call-pipeline.md)):\nthe answer comes from the execution context, not from any argument. Unlike `CELL`'s omitted\nreference, which falls back to volatile application state, `SHEET()`'s fallback is a stable\nproperty of where the formula lives — which is why the declared volatility here is\n`NonVolatile`.\n\n\n"
  },
  "signature": {
    "display": "SHEET([value])",
    "parameters": [
      {
        "description": null,
        "name": "value",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 1,
        "min": 0
      },
      "category": "Information functions",
      "classification": {
        "arg_preparation_profile": "RefsVisibleInAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "Composite",
        "host_interaction_class": "WorkbookState",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "Composite",
        "thread_safety_class": "HostSerialized",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Number of the sheet a reference or name points to",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the sheet number of the referenced sheet",
        "microsoft_url": "https://support.microsoft.com/en-us/office/sheet-function-44718b6f-8b87-47a1-a9d6-b701c06cff24"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "SHEET"
        },
        {
          "locale": "bg-BG",
          "name": "SHEET"
        },
        {
          "locale": "cs-CZ",
          "name": "SHEET"
        },
        {
          "locale": "da-DK",
          "name": "ARK"
        },
        {
          "locale": "de-DE",
          "name": "SHEET"
        },
        {
          "locale": "el-GR",
          "name": "SHEET"
        },
        {
          "locale": "en-AU",
          "name": "SHEET"
        },
        {
          "locale": "en-GB",
          "name": "SHEET"
        },
        {
          "locale": "en-US",
          "name": "SHEET"
        },
        {
          "locale": "es-ES",
          "name": "HOJA"
        },
        {
          "locale": "et-EE",
          "name": "SHEET"
        },
        {
          "locale": "fi-FI",
          "name": "TAULUKKO"
        },
        {
          "locale": "fr-FR",
          "name": "FEUILLE*"
        },
        {
          "locale": "he-IL",
          "name": "SHEET"
        },
        {
          "locale": "hr-HR",
          "name": "SHEET"
        },
        {
          "locale": "hu-HU",
          "name": "LAP"
        },
        {
          "locale": "id-ID",
          "name": "LEMBAR"
        },
        {
          "locale": "it-IT",
          "name": "SHEET"
        },
        {
          "locale": "ja-JP",
          "name": "SHEET"
        },
        {
          "locale": "ko-KR",
          "name": "SHEET"
        },
        {
          "locale": "lt-LT",
          "name": "SHEET"
        },
        {
          "locale": "lv-LV",
          "name": "SHEET"
        },
        {
          "locale": "nb-NO",
          "name": "ARK"
        },
        {
          "locale": "nl-NL",
          "name": "BLAD"
        },
        {
          "locale": "pl-PL",
          "name": "ARKUSZ"
        },
        {
          "locale": "pt-BR",
          "name": "SHEET"
        },
        {
          "locale": "pt-PT",
          "name": "FOLHA"
        },
        {
          "locale": "ro-RO",
          "name": "SHEET"
        },
        {
          "locale": "ru-RU",
          "name": "ЛИСТ"
        },
        {
          "locale": "sk-SK",
          "name": "SHEET"
        },
        {
          "locale": "sl-SI",
          "name": "SHEET"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "LIST"
        },
        {
          "locale": "sv-SE",
          "name": "BLAD"
        },
        {
          "locale": "th-TH",
          "name": "SHEET"
        },
        {
          "locale": "tr-TR",
          "name": "SAYFA"
        },
        {
          "locale": "uk-UA",
          "name": "SHEET"
        },
        {
          "locale": "vi-VN",
          "name": "SHEET"
        },
        {
          "locale": "zh-CN",
          "name": "SHEET"
        },
        {
          "locale": "zh-HK",
          "name": "SHEET"
        },
        {
          "locale": "zh-TW",
          "name": "SHEET"
        }
      ],
      "signature": {
        "display": "SHEET([value])",
        "parameters": [
          {
            "description": null,
            "name": "value",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "SHEET",
      "version_marker": null,
      "xlcall": {
        "code": "586",
        "symbol": "xlfSheet"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/sheet-function-44718b6f-8b87-47a1-a9d6-b701c06cff24"
  },
  "try_it": {
    "formula": "=SHEET(\"Sheet1\")"
  },
  "url": "https://handbook.dnacalc.com/functions/SHEET.html",
  "variants": [],
  "versions": []
}