I can count the number of "Subsection"
cells in a notebook by evaluating the following code at the BOTTOM of the notebook.
CurrentValue[{"CounterValue", "Subsection"}]
It only counts "Subsection"
cells above the cell which I evaluate, so you should put the code at the BOTTOM of the notebook so the count is not short.
I'm trying to capture this count externally from another notebook. I can't figure out how to do this as the code above must be evaluated in a cell inside the notebook being counted. And must be at the bottom.
Is there a way to do this programmatically? Or is there a more direct method?
Updated Response to Suggestion Below: @Dan7geo I am running M10.3 on MACOS 10.12. To illustrate why your second suggestion fails using a custom stylesheet, I created a simple notebook with 1 subsection cells and evaluated it using your code with no custom stylesheet. It works. However, if I apply a custom stylesheet it alters the result. See gif below.
Below is one expression from my stylesheet, that is adding to the count. There are 4 of them...
Cell[StyleData["Section"],
CellFrame->{{0, 0}, {0, 1}},
CellMargins->{{15, Inherited}, {8, 18}},
StyleKeyMapping->{"Tab" -> "Subsection"},
CellGroupingRules->{"SectionGrouping", 30},
PageBreakBelow->False,
CellFrameMargins->4,
CellFrameColor->GrayLevel[0.7],
LineSpacing->{1, 2},
LanguageCategory->"NaturalLanguage",
CounterIncrements->"Section",
CounterAssignments->{{"Subsection", 0}, {"Subsubsection", 0}, {"Item", 0}, {"Subitem", 0}, {
"Subsubitem", 0}, {"ItemNumbered", 0}, {"SubitemNumbered", 0}, {"SubsubitemNumbered", 0}},
MenuSortingValue->1250,
MenuCommandKey->"4",
FontFamily->"Gill Sans",
FontSize->28,
FontColor->RGBColor[0.7612268253604944, 0.29576562142366675`, 0.08555733577477684]]