5
$\begingroup$

I've learned a rather succinct way to delete tagged cells using NotebookLocate, but I would prefer the notebook did not scroll to the selection just for a delete operation. How can I delete tagged cells without the notebook scrolling?

Minimal example:

CellPrint[ExpressionCell[x^2, CellTags -> "oldcell"]]; Button["Remove old cell", { NotebookLocate["oldcell"]; NotebookDelete[]; }] 
$\endgroup$

2 Answers 2

7
$\begingroup$
Button["Remove old cell", NotebookFind[InputNotebook[], "oldcell",All, CellTags, AutoScroll -> False]; NotebookDelete[]] 
$\endgroup$
2
$\begingroup$

Another idea is to use Cells to find the cells instead of NotebookFind:

Button[ "Remove old cell", NotebookDelete @ Cells[CellTags -> "oldcell"] ] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.