Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Skip macro section when file doesn't exist

Status
Not open for further replies.

Oliversmo

IS-IT--Management
Feb 27, 2001
14
US
What is the easiest way to use if....else statements in an excel macro to skip sections of a macro if the file for that section isn't open or doesn't exist? An example of a section of the macro is as follows:

Windows("als.xls").Activate
Cells.Find(What:="RECORD COUNT", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.Copy
Windows("Ckbalan2002.xls").Activate
Range("AB1").Select
ActiveSheet.Paste
Windows("als.xls").Activate
With ActiveWindow

End With
Application.CutCopyMode = False
Cells.Find(What:="GRAND TOTAL", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Selection.Copy
Windows("Ckbalan2002.xls").Activate
Range("AC1").Select
ActiveSheet.Paste

There are 9 possible files that could be open/exist but we only use 6 every day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top