+ Reply to Thread
Results 1 to 9 of 9

Count All active workbooks

  1. #1
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Count All active workbooks

    Hi everyone,

    What is the suitable VBA code that counts all active workbooks and show the result in a msgbox?

    Thanks,
    Last edited by LoveCandle; 04-21-2009 at 04:42 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count All active workbooks

    Perhaps:

    Please Login or Register  to view this content.
    By active I presume you mean open... only 1 workbook is active at any given time.

  3. #3
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    Re: Count All active workbooks

    Number of open workbooks will be given by:

    Please Login or Register  to view this content.
    this won't double count workbooks that have two or more windows open.

    Richard
    Richard Schollar
    Microsoft MVP - Excel

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count All active workbooks

    Thanks for the correction.

  5. #5
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Count All active workbooks

    Thank you both, the code is working but it adds one to the total, Can you test the code??

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count All active workbooks

    Do you run a personal.xls file ?

  7. #7
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Count All active workbooks

    Yes, and I think this is the problem.
    Last edited by LoveCandle; 04-22-2009 at 05:47 AM.

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Count All active workbooks

    Given I presume you can't assume this to always be the case (ie other clients etc) then you will need to test if Personal.xls is open if it is to be discounted...

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    Re: Count All active workbooks

    Hi,

    Very nice useful code from you DonkeyOte,

    I used it as a function:
    Please Login or Register  to view this content.
    Thanks,
    Last edited by LoveCandle; 04-22-2009 at 05:20 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1