Hi Guys,
I'm trying to include error handling in the VBA below. So basically if the file (Workbooks("Pmet_Activity.csv")) doesn't exist, i'd like it to continue running ws(1). Thanks in advance!
Sub BNPAll()
Dim wbMO1 As Workbook, wbMO2 As Workbook
Set wbMO1 = Workbooks("Fx_Activity.csv")
Set wbMO2 = Workbooks("Pmet_Activity.csv")
Dim ws(1 To 2) As Worksheet
Set ws(1) = wbMO1.Sheets("Fx_Activity")
Set ws(2) = wbMO2.Sheets("Pmet_Activity")
On Error Resume Next
ws(2).Activate
ws(2).Range("A1").CurrentRegion.Offset(1, 0).Copy
ws(1).Activate 'run this line if ws2 doesn't exist
ws(1).Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Call BNPSort
wbMO1.Close False
wbMO2.Close False
End Sub
Ian
I'm trying to include error handling in the VBA below. So basically if the file (Workbooks("Pmet_Activity.csv")) doesn't exist, i'd like it to continue running ws(1). Thanks in advance!
Sub BNPAll()
Dim wbMO1 As Workbook, wbMO2 As Workbook
Set wbMO1 = Workbooks("Fx_Activity.csv")
Set wbMO2 = Workbooks("Pmet_Activity.csv")
Dim ws(1 To 2) As Worksheet
Set ws(1) = wbMO1.Sheets("Fx_Activity")
Set ws(2) = wbMO2.Sheets("Pmet_Activity")
On Error Resume Next
ws(2).Activate
ws(2).Range("A1").CurrentRegion.Offset(1, 0).Copy
ws(1).Activate 'run this line if ws2 doesn't exist
ws(1).Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Call BNPSort
wbMO1.Close False
wbMO2.Close False
End Sub
Ian