Results 1 to 5 of 5
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Application.Workbooks.Count

    I am getting a +1 return, that I think must be my Personal.xls which is hidden. How can I ignore hidden workbooks, so that I can control the number of visible workbooks, bearing in mind that I cannot use -1, because all users may not have a personal.xls open.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Like this:

    Code:
    Dim lngCount As Long
    Dim wbk As Workbook
    For Each wbk In Workbooks
      If wbk.Windows(1).Visible = True Then
    	lngCount = lngCount + 1
      End If
    Next wbk
    At the end of the loop, lngCount contains the number of visible workbooks.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='VegasNath' post='778538' date='05-Jun-2009 22:13']Hi,

    Application.Workbooks.Count

    I am getting a +1 return, that I think must be my Personal.xls which is hidden. How can I ignore hidden workbooks, so that I can control the number of visible workbooks, bearing in mind that I cannot use -1, because all users may not have a personal.xls open.[/quote]

    How about adding


    ...

    For Each wb In Workbooks
    If wb.Windows(1).Visible Then

    Do Something

    end if
    Next
    Jerry

  4. #4

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Parts of this topic were about other, unrelated questions. They can now be found in [topic="763987"]Delete multiple columns in VBA[/topic] and [topic="763988"]VLookup in VBA[/topic].

Posting Permissions

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