returns the CellObject corresponding to the cell directly above the currently evaluating cell.


starts looking from the given cell.


starts looking from the topmost selected item.

Details and Options

  • The evaluation of PreviousCell will not result in the selection or insertion point's changing position.
  • If the requested cell is not available or the top of the notebook is reached, PreviousCell will return None.
  • PreviousCell can return the first cell before the reference point that matches given criteria by specifying one or more of the following options:
  • CellIDcell IDs to match
    CellLabelIn/Out label strings to match
    CellStylenamed cell styles to match
    CellTagscell tags to match
    Evaluatorcells that match the specified evaluator
    GeneratedCellmatch only generated output cells if True, or only non-generated cells if False
  • PreviousCell[cellobj] of an inline cell will return the previous inline cell in the same cell. PreviousCell[NotebookSelection[nbobj]] will always return the previous regular cell, regardless of whether an inline cell is presently selected.


Basic Examples  (3)

Get the CellObject for the previous cell:

Read this caption cell into the kernel:

There are no "Section" style cells above this point in this notebook:

Wolfram Research (2014), PreviousCell, Wolfram Language function, (updated 2020).


Wolfram Research (2014), PreviousCell, Wolfram Language function, (updated 2020).


Wolfram Language. 2014. "PreviousCell." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020.


Wolfram Language. (2014). PreviousCell. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_previouscell, author="Wolfram Research", title="{PreviousCell}", year="2020", howpublished="\url{}", note=[Accessed: 20-July-2024 ]}


@online{reference.wolfram_2024_previouscell, organization={Wolfram Research}, title={PreviousCell}, year={2020}, url={}, note=[Accessed: 20-July-2024 ]}