# Exclude Sections/Subsections/… from evaluation

I'm working on a large notebook and I want to exclude some sections and subsections from being evaluated when I evaluate the whole notebook.

Is there a way to exclude specific sections or subsections from the notebook evaluation while maintaining their original format? Or even better, format them e.g. by adding a gray background?

-
Rather than specify which sections to not evaluate, you can specify which you do want to evaluate, by setting them to be initialization cells, and evaluating only initialization cells. –  jVincent Feb 15 '13 at 11:51
Or, you can select those cells that you don't need to evaluate and comment them (Edit menu -> Un/Comment Selection). –  VLC Feb 15 '13 at 12:08
See mathematica.stackexchange.com/questions/14466/… for another approach. –  cormullion Feb 15 '13 at 12:24

This solution only works in version 9. Create a private stylesheet, and add style cells for any Section, etc., styles that you want to create using the following pattern:

Cell[StyleData["NonEvaluatingSection", StyleDefinitions -> StyleData["Section"]],
PrivateCellOptions->{"CellGroupBaseStyle"->{Evaluatable -> False,
Background->RGBColor[0.8, 0.8, 0.8]}},

"CellGroupBaseStyle" is new to version 9, and it allows you to layer in options to all cells which are grouped by the given style. So, in this case, we have a style "NonEvaluatingSection", which has all of the properties of the style "Section", except that it adds a background and Evaluatable->False to itself and all of the cells grouped by it. The option is not documented, but that's just an oversight. It will be in a future release.