+ Reply to Thread
Results 1 to 4 of 4

skip empty sheets

  1. #1
    Rob
    Guest

    skip empty sheets

    I am using a script downloaded from a web page the code
    below is missing out my charts from the list of results
    due to the skip empty sheets part. Please can someone
    tell me how to take it out so the charts are part of the
    list!

    Thanks

    ' Add the checkboxes
    TopPos = 40
    For i = 1 To ActiveWorkbook.Worksheets.Count
    Set CurrentSheet = ActiveWorkbook.Worksheets(i)
    ' Skip empty sheets and hidden sheets
    If Application.CountA(CurrentSheet.Cells) <> 0
    And _
    CurrentSheet.Visible Then
    SheetCount = SheetCount + 1
    PrintDlg.CheckBoxes.Add 78, TopPos, 150, 16.5
    PrintDlg.CheckBoxes(SheetCount).Text = _
    CurrentSheet.Name
    TopPos = TopPos + 13
    End If
    Next i

    ' Move the OK and Cancel buttons
    PrintDlg.Buttons.Left = 240

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,519
    Hi
    try

    CurrentSheet.UsedRange.Value <> ""

    hope this helps

    jindon

  3. #3
    gocush
    Guest

    RE: skip empty sheets

    Can you restate or explain what you mean by:

    "the code below is missing out my charts from the list of results
    due to the skip empty sheets part."

    "Rob" wrote:

    > I am using a script downloaded from a web page the code
    > below is missing out my charts from the list of results
    > due to the skip empty sheets part. Please can someone
    > tell me how to take it out so the charts are part of the
    > list!
    >
    > Thanks
    >
    > ' Add the checkboxes
    > TopPos = 40
    > For i = 1 To ActiveWorkbook.Worksheets.Count
    > Set CurrentSheet = ActiveWorkbook.Worksheets(i)
    > ' Skip empty sheets and hidden sheets
    > If Application.CountA(CurrentSheet.Cells) <> 0
    > And _
    > CurrentSheet.Visible Then
    > SheetCount = SheetCount + 1
    > PrintDlg.CheckBoxes.Add 78, TopPos, 150, 16.5
    > PrintDlg.CheckBoxes(SheetCount).Text = _
    > CurrentSheet.Name
    > TopPos = TopPos + 13
    > End If
    > Next i
    >
    > ' Move the OK and Cancel buttons
    > PrintDlg.Buttons.Left = 240
    >


  4. #4
    Mike Fogleman
    Guest

    Re: skip empty sheets

    I believe he means that if his sheet contains only charts, then the line:

    If Application.CountA(CurrentSheet.Cells) <> 0
    considers it to be "empty" and does not make a checkbox for that sheet. I
    would think he should add another test for Objects.Count <>0

    If Application.CountA(CurrentSheet.Cells) <> 0 _
    And CurrentSheet.Objects.count <>0 _
    And CurrentSheet.Visible Then
    .... 'make checkboxes
    End If

    Mike F

    "gocush" <[email protected]/delete> wrote in message
    news:[email protected]...
    > Can you restate or explain what you mean by:
    >
    > "the code below is missing out my charts from the list of results
    > due to the skip empty sheets part."
    >
    > "Rob" wrote:
    >
    >> I am using a script downloaded from a web page the code
    >> below is missing out my charts from the list of results
    >> due to the skip empty sheets part. Please can someone
    >> tell me how to take it out so the charts are part of the
    >> list!
    >>
    >> Thanks
    >>
    >> ' Add the checkboxes
    >> TopPos = 40
    >> For i = 1 To ActiveWorkbook.Worksheets.Count
    >> Set CurrentSheet = ActiveWorkbook.Worksheets(i)
    >> ' Skip empty sheets and hidden sheets
    >> If Application.CountA(CurrentSheet.Cells) <> 0
    >> And _
    >> CurrentSheet.Visible Then
    >> SheetCount = SheetCount + 1
    >> PrintDlg.CheckBoxes.Add 78, TopPos, 150, 16.5
    >> PrintDlg.CheckBoxes(SheetCount).Text = _
    >> CurrentSheet.Name
    >> TopPos = TopPos + 13
    >> End If
    >> Next i
    >>
    >> ' Move the OK and Cancel buttons
    >> PrintDlg.Buttons.Left = 240
    >>




+ 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