# Is it possible to modify the options for a particular cell from another cell? [duplicate]

I was wondering if I can toggle the "CellOpen" state from a cell (or bunch of cells) from another cell. i.e. I am imagining having a manipulate command along the lines of:

Manipulate[If[show, "set the status of these cells to open",
"set the status of these cells to closed"],
{{show, True, "Show cells"}, {True, False}}]


where for example "all these cells" could be all Output cells, or a subset of those as defined by some list.

Thanks

-

## marked as duplicate by Jacob Akkerboom, m_goldberg, R. M.♦Jan 8 '14 at 18:53

Yes! You can find a Cell that has tag "tag" using Cells[nb, CellTags->"tag"]. Then you can set the option you want using SetOptions. I made some code that generates a notebook, so that it is clear which things should be in different cells. In the generated notebook, the master cell can change the background of the slave cell. Try to put another value than LightGreen.

nb =
NotebookPut@
Notebook[
{
Cell[
BoxData[MakeBoxes[
SetOptions[
Cells[CellTags -> "Slave"] // First, {GeneratedCell -> False,
Background -> LightGreen}]]]
,
"Input"
,
CellTags -> "Master"
]

,

Cell[BoxData[MakeBoxes[Print["I am not evaluated :("]]]
,
"Input"
,
CellTags -> "Slave"
]

}
];

NotebookEvaluate[nb, EvaluationElements -> {"Tags" -> {"Master"}},
InsertResults -> True]

-
That's great. Thanks. – tbtom Jan 8 '14 at 15:58