Cells
Cells[]
returns a list of CellObject expressions corresponding to cells in the current notebook.
Cells[obj]
returns the list of CellObject expressions in obj.
Cells[NotebookSelection[notebook]]
returns the list of CellObject expressions for currently selected cells.
Details and Options
- Cells always returns a list if the value of obj is valid. Otherwise, it returns $Failed.
- obj may be a NotebookObject or a CellObject. If obj is a CellObject, then Cells returns the inline cells in the specified cell.
- Cells can further refine the list of returned CellObject expressions by specifying one or more of the following options.
-
AttachedCell if True, match only cells created by AttachCell CellID cell IDs to match CellLabel In/Out label strings to match CellStyle named cell styles to match CellTags cell tags to match CounterAssignments cells whose counter values match the given value CounterIncrements cells that increment the given counters DockedCell if True, match only cells created by DockedCells Evaluator cells that match the specified evaluator StripCellGrouping whether to include cell grouping information in the result GeneratedCell match only generated output cells if True, or only non-generated cells if False - When multiple options are passed to Cells, the return result will only include CellObject expressions matching cells that meet all conditions.
- If a list of values is given to any single option of Cells, then it will match any of the given values.
- If the selection in a notebook is inside of a cell, then Cells[NotebookSelection[notebook]] returns the cell containing the selection.
- With the setting StripCellGroupingFalse, cell groups will be represented by possibly nested lists in the result.
Examples
open allclose allBasic Examples (4)
Scope (5)
Return a list of any selected cells:
Give a list of values to an option to select cells that match any of the values:
Use multiple options to select the intersection of cells that match all of the listed criteria:
Use NotebookSelection to identify a selected cell:
Use NotebookSelection to identify all selected cells in a range selection:
Options (9)
Applications (2)
Properties & Relations (1)
Cells only scans top-level cells for matching criteria, not inline cells:
However, if the selection is in an inline cell, you can get the inline cell's CellObject:
Possible Issues (1)
Cells returns $Failed if the NotebookObject does not exist:
Text
Wolfram Research (2012), Cells, Wolfram Language function, https://reference.wolfram.com/language/ref/Cells.html (updated 2024).
CMS
Wolfram Language. 2012. "Cells." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Cells.html.
APA
Wolfram Language. (2012). Cells. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Cells.html