Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

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

share|improve this question

marked as duplicate by Jacob Akkerboom, m_goldberg, rm -rf Jan 8 at 18:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

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]
share|improve this answer
    
That's great. Thanks. –  tbtom Jan 8 at 15:58

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