Let me start by saying that I'm fairly new to making macros and that I'm teaching myself. Any help would be greatly appriciated.
I created this macro for some reports I run at work. What it should do is open a file, format it, copy a cell, paste that into a new sheet then save it under a new name. That all works, the issue is in the jump commands. They way I'd like it to work is; if there is not a particular file it skips that section and moves to the next. That works but only if there is one jump, if multiple jumps are needed an error occurs. Any tips would be helpful. there are 4 possible jumps total. I've put part of the code below;
'Dole
'open original file
On Error GoTo Eaches
Workbooks.Open Filename:="G:\Banana-ddd-Dole.xls"
Windows("Banana-ddd-Dole.xls").Activate
'format file
(removed to save space)
'copy function
Range("I5").Select
Selection.Copy
'open copy location
Windows("MACRO - banana report.xls").Activate
Sheets("E-mail report").Select
'need paste function
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Banana-ddd-Dole.xls").Activate
'save file w/ julian date
'Format(DateDiff("d", "1/1" & "/" & Year(Date), Date) + 1, "000")
ActiveWorkbook.SaveAs Filename:="G:\Banana-" & Format(DateDiff("d", "1/1" & "/" & Year(Date), Date) + 1, "000") & "-Dole" & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
'Eaches
Eaches:
'open original file
On Error GoTo Mini
Workbooks.Open Filename:="G:\Banana-ddd-Eaches.xls"
Windows("Banana-ddd-Eaches.xls").Activate
'format file
(removed to save space)
'copy function
Range("I5").Select
Selection.Copy
'open copy location
Windows("MACRO - banana report.xls").Activate
Sheets("E-mail report").Select
'need paste function
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Banana-ddd-Eaches.xls").Activate
'save file w/ julian date
'Format(DateDiff("d", "1/1" & "/" & Year(Date), Date) + 1, "000")
ActiveWorkbook.SaveAs Filename:="G:\Banana-" & Format(DateDiff("d", "1/1" & "/" & Year(Date), Date) + 1, "000") & "-Eaches" & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
Bookmarks