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[];
}]
| improve this question | | | | |
$\endgroup$
7
$\begingroup$
Button["Remove old cell",
NotebookFind[InputNotebook[], "oldcell",All, CellTags, AutoScroll -> False];
NotebookDelete[]]
| improve this answer | | | | |
$\endgroup$
2
$\begingroup$

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.