+ Reply to Thread
Results 1 to 5 of 5

How to tell if multiple sheets are selected?

  1. #1
    Mike Weaver
    Guest

    How to tell if multiple sheets are selected?

    How can I tell if multiple sheets have been selected?

    Thanks in advance

    Mike



  2. #2
    JMB
    Guest

    RE: How to tell if multiple sheets are selected?

    if activewindow.SelectedSheets.Count > 1

    "Mike Weaver" wrote:

    > How can I tell if multiple sheets have been selected?
    >
    > Thanks in advance
    >
    > Mike
    >
    >
    >


  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Mike,

    It is a good practice to preface Window operations with the application to which they belong. Functions like ActiveWindow are envrironmentally dependent. If you were troubleshooting your code in the VBA Editor, ActiveWindow would assume you are referring to the active window in the VBA Editor and not Excel. To prevent these problems qualify your object methods like this...

    Excel.ActiveWindow.SelectedSheets.Count

    Sincerely,
    Leith Ross

  4. #4
    Dave Peterson
    Guest

    Re: How to tell if multiple sheets are selected?

    I stepped through this code in the VBE in book2.xls with book1.xls active in
    excel:

    Option Explicit
    Sub testme01()
    Debug.Print ActiveWindow.Caption
    End Sub

    I saw this in the immediate window:
    book1.xls



    Leith Ross wrote:
    >
    > Hello Mike,
    >
    > It is a good practice to preface Window operations with the application
    > to which they belong. Functions like ActiveWindow are envrironmentally
    > dependent. If you were troubleshooting your code in the VBA Editor,
    > ActiveWindow would assume you are referring to the active window in the
    > VBA Editor and not Excel. To prevent these problems qualify your object
    > methods like this...
    >
    > Excel.ActiveWindow.SelectedSheets.Count
    >
    > Sincerely,
    > Leith Ross
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=509245


    --

    Dave Peterson

  5. #5
    Mike Weaver
    Guest

    Re: How to tell if multiple sheets are selected?

    Thanks. That gets me headed in the right direction.

    Mike

    "Leith Ross" <[email protected]> wrote
    in message news:[email protected]...
    >
    > Hello Mike,
    >
    > It is a good practice to preface Window operations with the application
    > to which they belong. Functions like ActiveWindow are envrironmentally
    > dependent. If you were troubleshooting your code in the VBA Editor,
    > ActiveWindow would assume you are referring to the active window in the
    > VBA Editor and not Excel. To prevent these problems qualify your object
    > methods like this...
    >
    > Excel.ActiveWindow.SelectedSheets.Count
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile:
    > http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=509245
    >




+ 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