2 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/ edited Apr 13 '17 at 12:55 Per george2079'sgeorge2079's recommendation and Yves Klett'sYves Klett's reference to http://mathematica.stackexchange.com/questions/22068/how-to-build-and-operate-a-master-notebookHow to build and operate a master Notebook?, I think this is better closed as a duplicate or not at all, since it is a slight extension of the linked Q&A. There may be times when iterating a notebook is useful. At this time, it's hard for me to imagine how the computation wouldn't be better accomplished by a package, as Yves recommended in another comment, or sometimes just by a function. Nonetheless, here is an example: Suppose this notebook is saved in "Sample.nb": sampleNB = Notebook[{Cell[ BoxData[RowBox[{"res", " ", "=", " ", RowBox[{"{", RowBox[{"res", ",", RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}]}], "}"}]}]], "Input"]}]  Suppose further it is opened with nb = NotebookOpen["Sample.nb"]; then the result will be equivalent to nb = NotebookPut[sampleNB];  Then we can iterate evaluation of the notebook with the following: Block[{res = {}}, Do[NotebookEvaluate[nbobj], {i, 3}, {j, 2}]; Flatten@res] (* Caveat: Flatten won't work right if the value of f has the head List *) (* {f[1, 1], f[1, 2], f[2, 1], f[2, 2], f[3, 1], f[3, 2]} *)  Per george2079's recommendation and Yves Klett's reference to http://mathematica.stackexchange.com/questions/22068/how-to-build-and-operate-a-master-notebook, I think this is better closed as a duplicate or not at all, since it is a slight extension of the linked Q&A. There may be times when iterating a notebook is useful. At this time, it's hard for me to imagine how the computation wouldn't be better accomplished by a package, as Yves recommended in another comment, or sometimes just by a function. Nonetheless, here is an example: Suppose this notebook is saved in "Sample.nb": sampleNB = Notebook[{Cell[ BoxData[RowBox[{"res", " ", "=", " ", RowBox[{"{", RowBox[{"res", ",", RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}]}], "}"}]}]], "Input"]}]  Suppose further it is opened with nb = NotebookOpen["Sample.nb"]; then the result will be equivalent to nb = NotebookPut[sampleNB];  Then we can iterate evaluation of the notebook with the following: Block[{res = {}}, Do[NotebookEvaluate[nbobj], {i, 3}, {j, 2}]; Flatten@res] (* Caveat: Flatten won't work right if the value of f has the head List *) (* {f[1, 1], f[1, 2], f[2, 1], f[2, 2], f[3, 1], f[3, 2]} *)  Per george2079's recommendation and Yves Klett's reference to How to build and operate a master Notebook?, I think this is better closed as a duplicate or not at all, since it is a slight extension of the linked Q&A. There may be times when iterating a notebook is useful. At this time, it's hard for me to imagine how the computation wouldn't be better accomplished by a package, as Yves recommended in another comment, or sometimes just by a function. Nonetheless, here is an example: Suppose this notebook is saved in "Sample.nb": sampleNB = Notebook[{Cell[ BoxData[RowBox[{"res", " ", "=", " ", RowBox[{"{", RowBox[{"res", ",", RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}]}], "}"}]}]], "Input"]}]  Suppose further it is opened with nb = NotebookOpen["Sample.nb"]; then the result will be equivalent to nb = NotebookPut[sampleNB];  Then we can iterate evaluation of the notebook with the following: Block[{res = {}}, Do[NotebookEvaluate[nbobj], {i, 3}, {j, 2}]; Flatten@res] (* Caveat: Flatten won't work right if the value of f has the head List *) (* {f[1, 1], f[1, 2], f[2, 1], f[2, 2], f[3, 1], f[3, 2]} *)  1 answered Jul 11 '16 at 16:05 Michael E2 159k1313 gold badges217217 silver badges516516 bronze badges Per george2079's recommendation and Yves Klett's reference to http://mathematica.stackexchange.com/questions/22068/how-to-build-and-operate-a-master-notebook, I think this is better closed as a duplicate or not at all, since it is a slight extension of the linked Q&A. There may be times when iterating a notebook is useful. At this time, it's hard for me to imagine how the computation wouldn't be better accomplished by a package, as Yves recommended in another comment, or sometimes just by a function. Nonetheless, here is an example: Suppose this notebook is saved in "Sample.nb": sampleNB = Notebook[{Cell[ BoxData[RowBox[{"res", " ", "=", " ", RowBox[{"{", RowBox[{"res", ",", RowBox[{"f", "[", RowBox[{"i", ",", "j"}], "]"}]}], "}"}]}]], "Input"]}]  Suppose further it is opened with nb = NotebookOpen["Sample.nb"]; then the result will be equivalent to nb = NotebookPut[sampleNB];  Then we can iterate evaluation of the notebook with the following: Block[{res = {}}, Do[NotebookEvaluate[nbobj], {i, 3}, {j, 2}]; Flatten@res] (* Caveat: Flatten won't work right if the value of f has the head List *) (* {f[1, 1], f[1, 2], f[2, 1], f[2, 2], f[3, 1], f[3, 2]} *)