Two buttons of my ButtonTools palette (originally written for Mathematica 4, published here:
http://www.mertig.com/mathdepot/ ) will do what you want.
I refactored the code here. So just evaluate the code below. Then select the notebook you want to partially evaluate. One button will evaluate all cells from the top until the insertion point, the other all cells downward.
I use it all the time since often I do not want to reevaluate the whole notebook and it is much quicker to press a button than to select a bunch of cells.
Also, this is of course useful for development/debugging/documentation. The code itself should be as much functional as possible, obviously.
CreatePalette[{Button[Style["E\[UpArrow]", "Section"],
SelectionMove[SelectedNotebook[], After, Cell];
NotebookWrite[SelectedNotebook[],
Cell["bishierherundnichtweiter", "Input", CellOpen -> False,
ShowCellBracket -> False,
CellElementSpacings -> {"CellMinHeight" -> 0},
CellMargins -> {{0, 0}, {0, 0}}]];
SelectionMove[SelectedNotebook[], Before, Notebook];
Catch[
Do[SelectionMove[SelectedNotebook[], Next, Cell];
Module[ {r},
If[ MatchQ[r = NotebookRead[SelectedNotebook[]],
Cell["bishierherundnichtweiter", ___]],
NotebookDelete[SelectedNotebook[]];
Throw[0],
SelectionEvaluate[SelectedNotebook[]]
]
], {100000}]]],
Button[Style["E\[DownArrow]", "Section"],
SelectionMove[SelectedNotebook[], Before, Cell];
NotebookWrite[SelectedNotebook[],
Cell["Start Evaluation here", "SmallText", CellOpen -> True,
CellMargins -> {{0, 0}, {0, 0}},
CellTags -> "hiergehtslos"]];
SelectionMove[SelectedNotebook[], After, Notebook];
NotebookWrite[SelectedNotebook[],
Cell["Stop Evaluation here", "SmallText", CellOpen -> True,
ShowCellBracket -> True, CellMargins -> {{0, 0}, {0, 0}},
CellTags -> "undhieristschluss"]];
NotebookFind[SelectedNotebook[], "hiergehtslos", All, CellTags];
Catch[
Do[SelectionMove[SelectedNotebook[], Next, Cell];
Module[ {r},
If[ MatchQ[r = NotebookRead[SelectedNotebook[]],
Cell["Stop Evaluation here", "SmallText", ___]],
Throw[0],
SelectionEvaluate[SelectedNotebook[]]
]
], {10000}]];
NotebookFind[SelectedNotebook[], "hiergehtslos", All,
CellTags, AutoScroll -> False];
NotebookFind[SelectedNotebook[], "hiergehtslos", All, CellTags,
AutoScroll -> False];
NotebookDelete[SelectedNotebook[]]*
NotebookFind[SelectedNotebook[], "undhieristschluss", All,
CellTags];
NotebookFind[SelectedNotebook[], "undhieristschluss", All,
CellTags];
NotebookDelete[SelectedNotebook[]]]}]
cell->Add tag). Give one tag name to all the cells you are interested in executing as one group, say "z". Then you can later typeNotebookLocate["z"]This will select all those cells. Then use some notebook command to evaluate selected tags. Look at theNotebook*[]and related commands to programmatically Evaluate selected cells. I do not know much about this. – Nasser Nov 19 '12 at 1:37DoorTable, instead of code-gymnastics to control cell evaluation. You might also want to look into putting your stuff in a package. – rm -rf♦ Nov 19 '12 at 1:43