Consulting

Results 1 to 5 of 5

Thread: Solved: Which sheets are select in a workbook?

  1. #1

    Solved: Which sheets are select in a workbook?

    Hi everybody

    I need a macro that count how many sheets are select in a workbook and wichone are selected. or just wichone are selected...


    i think is very simple code, but i have no ideia.
    I seached in te forum, but no answer...



    Thanks everybody
    Sorry for the poor english

  2. #2
    I had guessed, but is there a reason? It seems superfluous - the first example clearly identify the item you choose. We have code in Excel 2003 that is not in Excel 2007 and it is mainly the Select class method leaves that causes problems. I try to understand the underlying logic instead of just trying random combinations to select and activate the statements that come with the right.

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,366
    Location
    Quote Originally Posted by ferrugo
    Hi everybody

    I need a macro that count how many sheets are select in a workbook and wichone are selected. or just wichone are selected...


    i think is very simple code, but i have no ideia.
    I seached in te forum, but no answer...



    Thanks everybody
    Sorry for the poor english
    Presuming in the active window:
    [vba]Sub exa()
    Dim sh
    Dim msg$


    For Each sh In ActiveWindow.SelectedSheets
    If sh.Type = -4167 Then
    msg$ = msg$ & sh.Name & vbCrLf
    End If
    Next

    msg$ = "Selected sheets are:" & String(2, vbCrLf) & msg$ & vbCrLf & "Count is: " & _
    ActiveWindow.SelectedSheets.Count
    MsgBox msg$, vbOKOnly, vbNullString

    End Sub[/vba] Hope that helps,

    Mark

  4. #4
    wowww....

    Thanks everybody, and GTO....

    this is the code that a looking for.

    For Each sh In ActiveWindow.SelectedSheets
    If sh.Type = -4167 Then

    i will study that.
    many thanks

  5. #5
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,366
    Location
    You are most welcome. The -4167 is for a worksheet, so it will disregard chartsheets etc.

Posting Permissions

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