Excel: Obtaining a Count of the Currently Open Windows

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 "WindowCount" (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 "-MacroName!WindowCount", where "MacroName" is the name of the macro sheet containing the WindowCount macro.

  3. Click OK.

Upon running the macro, the cell containing "=COLUMNS(WINDOWS())" (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.


KBCategory: kbother
KBSubcategory:

Additional reference words: noupd


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.