Vindaloo
New Member
- Joined
- Jul 15, 2014
- Messages
- 29
I keep getting this error no matter where I stick End If functions. I'm hoping a fresh pair of eyes can tell me where this is coming from.
Code:
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
Dim TestStr As String
Dim ws As Worksheet
i = 11
Application.Calculation = xlCalculationManual
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
TestStr = ""
On Error Resume Next
TestStr = Dir(Path)
On Error GoTo 0
If TestStr = "" Then
'Do Nothing
Else
Workbooks.Open Filename:= _
Path
End If
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "BnrTrans" And ws.Name <> "PAT PAYMENTS" And ws.Name <> "COMM INS" And ws.Name <> "DRAWER 1" And ws.Name <> "DRAWER 2" And ws.Name <> "CREDIT CARDS" And ws.Name <> "DRAWER 3" And ws.Name <> "CLINIC DISP" And ws.Name <> "WHITE RECEIPTS" And ws.Name <> "DEPOSIT DIST" And ws.Name <> "DDIS Page 1 Bnr" And ws.Name <> "DDIS Page 2 Bnr" And ws.Name <> "DDIS-CHG CARDS Bnr" And ws.Name <> "DDIS-WIRES Bnr" And ws.Name <> "WORK AREA" Then
Range("A3:F500").Select
Selection.Copy
Windows("DDIS Batch Generic Data Importer.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).Select
Windows(File_Name).Close savechanges:=False
Windows("DDIS Batch Generic Data Importer.xlsm").Activate
Sheets("Control").Select
End If
i = i + 1
Loop
End With
Application.DisplayAlerts = True
Application.AskToUpdateLinks = True
Application.ScreenUpdating = False
Application.Calculation = xlCalculationAutomatic
End Sub