Macro Help...Skipping tabs not present

Posted on 2012-08-13
Last Modified: 2012-09-11

I recorded a macro that essentially grabs tabs from a source spreadsheet, titles them, and saves them in an appropriate folder. The problem begins when the source spreadsheet comes in next month without one of the tabs that was present in the prior month. What is the easiest way to tell the macro to skip grabbing the tab if it isn't present? Currently, the macro bugs out when the source sheet is missing a tab that was present in the prior month. Thanks is advance.
Question by:cdcamp77
    LVL 39

    Accepted Solution

    you can do

    on error resume next
    debug.print sheets("Missing tab").cells(1,1)
    if err=0 then
    'tab Missing tab exists
    'tab Missing tab doesn't exist
    end if
    on error goto 0

    Open in new window

    LVL 44

    Assisted Solution

    Iterate the worksheets as a collection, rather than by name.
    Dim wks As Worksheet
    For Each wks In ActiveWorkbook.Worksheets
        'put your processing code here

    Open in new window

    LVL 44

    Expert Comment

    by:Martin Liss
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now