Vindaloo
New Member
- Joined
- Jul 15, 2014
- Messages
- 29
I am attempting to use this to pull multiple tabs from multiple workbooks. I would like this macro to skip over files that do not exist. The error manager worked for one error, but crashed on the second. I also tried the Dir method, but couldn't figure out where to put it. Any thoughts?
PHP:
Sub Import()
'
' Import Macro
'
'
Dim File_Name As String
Dim High_Folder As String
Dim Low_Folder As String
Dim Path As String
Dim i As Integer
i = 11
Application.ScreenUpdating = False
With Worksheets("Control")
Do Until .Cells(i, 4).Value = ""
Sheets("Control").Select
File_Name = Cells(i, 4).Value
High_Folder = Cells(i, 5).Value
Low_Folder = Cells(i, 6).Value
Path = Cells(i, 7).Value
Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
Workbooks.Open Filename:= _
Path
On Error Resume Next
Sheets("WIRES-OTHER").Select
Range("A3:F64").Select
Selection.Copy
Windows("DDIS Batch Reconcile.xlsm").Activate
Sheets("WIRES-OTHER").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "SOURCE"
Range("A2:F10000").Select
ActiveWorkbook.Worksheets("WIRES-OTHER").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("WIRES-OTHER").Sort.SortFields.Add Key:=Range( _
"A3:A10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("WIRES-OTHER").Sort
.SetRange Range("A2:F10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Windows(File_Name).Activate
Sheets("Wires Input").Select
Rows("5:5").Select
Selection.AutoFilter
Selection.AutoFilter
Range("A6:G400").Select
Selection.Copy
Windows("DDIS Batch Reconcile.xlsm").Activate
Sheets("Wires Input").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "SETTLEMENT DATE"
Range("A2:H10000").Select
ActiveWorkbook.Worksheets("Wires Input").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Wires Input").Sort.SortFields.Add Key:=Range( _
"A3:A10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Wires Input").Sort
.SetRange Range("A2:H10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Windows(File_Name).Activate
Sheets("PAT PAYMENTS").Select
Range("A6:I400").Select
Selection.Copy
Windows("DDIS Batch Reconcile.xlsm").Activate
Sheets("PAT PAYMENTS").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Date"
Range("A2:I10000").Select
ActiveWorkbook.Worksheets("PAT PAYMENTS").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("PAT PAYMENTS").Sort.SortFields.Add Key:=Range( _
"A3:A10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("PAT PAYMENTS").Sort
.SetRange Range("A2:I10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Windows(File_Name).Activate
Sheets("COMM INS").Select
Range("A6:l400").Select
Selection.Copy
Windows("DDIS Batch Reconcile.xlsm").Activate
Sheets("COMM INS").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "BATCH NUM"
Range("A2:l10000").Select
ActiveWorkbook.Worksheets("COMM INS").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("COMM INS").Sort.SortFields.Add Key:=Range( _
"A3:A10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("COMM INS").Sort
.SetRange Range("A2:l10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Windows(File_Name).Activate
Sheets("CREDIT CARDS").Select
Range("A6:l400").Select
Selection.Copy
Windows("DDIS Batch Reconcile.xlsm").Activate
Sheets("CREDIT CARDS").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "SETTLEMENT DATE"
Range("A2:l10000").Select
ActiveWorkbook.Worksheets("CREDIT CARDS").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("CREDIT CARDS").Sort.SortFields.Add Key:=Range( _
"A3:A10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("CREDIT CARDS").Sort
.SetRange Range("A2:l10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Windows(File_Name).Close savechanges:=False
Windows("DDIS Batch Reconcile.xlsm").Activate
Sheets("Control").Select
i = i + 1
Loop
End With
Application.DisplayAlerts = True
Application.AskToUpdateLinks = True
Application.ScreenUpdating = False
End Sub