Microsoft KB Archive/66383

{| = Excel: Obtaining a Count of the Currently Open Windows =
 * width="100%"|

Last reviewed: November 2, 1994

Article ID: Q66383

SUMMARY
To count the number of windows that are currently open in Microsoft Excel, including those that are hidden, enter the following commands on a macro sheet:

+---+-+  |   |          A          | +---+-+  | 1 | WindowCount         | +---+-+  | 2 | =COLUMNS(WINDOWS) | <-- Enter as an array formula by pressing +---+-+    COMMAND+ENTER. | 3 | =Return          | +---+-+ (Note: This will not count Excel 3.00 Add-in macros) To define the commands as a macro, do the following:


 * 1) Select the cell containing &quot;WindowCount&quot; (in this example, A1).
 * 2) From the Formula menu, choose Define Name.
 * 3) Under Macro, select Command.
 * 4) Click OK.

To run the macro, do the following:
 * 1) From the Macro menu, choose Run.
 * 2) Select &quot;-MacroName!WindowCount&quot;, where &quot;MacroName&quot; is the name of the macro sheet containing the WindowCount macro.
 * 3) Click OK.

Upon running the macro, the cell containing &quot;=COLUMNS(WINDOWS)&quot; (in this example, A2) will return the number of Excel windows that are currently open. Note: To display the values that the macro commands return instead of the formulas, choose Display from the Options menu, deselect Formulas, and click OK, or press COMMAND+~ (TILDE) to toggle the display between formulas and values.
 * }