• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Macro Help...Skipping tabs not present

Hi,

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.
0
cdcamp77
Asked:
cdcamp77
2 Solutions
 
nutschCommented:
you can do

on error resume next
debug.print sheets("Missing tab").cells(1,1)

if err=0 then
'tab Missing tab exists
else
'tab Missing tab doesn't exist
err.clear
end if

on error goto 0

Open in new window


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

Open in new window

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now