+ Reply to Thread
Results 1 to 4 of 4

Closing VBA - condition: number of open workbooks

  1. #1
    Registered User
    Join Date
    07-10-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    18

    Question Closing VBA - condition: number of open workbooks

    Dear Excellers,

    I'm creating a code that I'd like to bind to a button.
    I'd like the code to exit Excel completely if there aren't any other workbooks open.
    Should there be more workbooks open, then it should just close the workbook inwhich the code is placed.

    Current thoughts on the code:
    Please Login or Register  to view this content.
    So could you either help me out by providing the code that counts the number of open workbooks or hand me a new code with a different view on things.

    Would be greatly appreciated.

    Regards,
    MitchelDZ

  2. #2
    Registered User
    Join Date
    07-10-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Closing VBA - condition: number of open workbooks

    I just noticed I sayd: Close VBA in the title. Ofcourse I meant Excel.
    Any way to change that?

  3. #3
    Registered User
    Join Date
    07-10-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Closing Excel - condition: number of open workbooks

    I found this code:
    Please Login or Register  to view this content.
    But after testing it, it doesn't really work as:
    It returns the value 1 in every situation.

    I tested it with:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-10-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Closing VBA - condition: number of open workbooks

    I figured it out with google:

    Code shouldn't be
    Please Login or Register  to view this content.

    but

    Please Login or Register  to view this content.

    Solved, yay

+ 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