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.
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.