Can someone please tell me where the problem is in this code. I get an error 400 when i run it.
Code:
Sub ImportInvoices()
fx = Dir("g:\marketing\invoices\" & "MISC*.xls")
Hx = Sheets("MAIN REGISTER").Cells(Rows.Count, 1).End(xlUp).Row
Ix = Hx + 1
Jx = CInt(Mid(Sheets("MAIN REGISTER").Cells(Hx, 1), 5, 4))
Cells(Ix, 1).Select
Kx = Ix
Do While Len(fx) > 0
Gx = CInt(Mid(fx, 5, 4))
If Gx > Jx Then
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Selection.EntireRow.Insert
Limit = Cells(Kx, Columns.Count).End(xlToLeft).Column
ActiveCell.Formula = "MISC" & Gx
ActiveCell.Offset(0, 2).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$R$13"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$D$12"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$D$12"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$E$31"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$A$21"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$D$11"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$E$39"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$E$40"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Formula = "=[MISC" & Gx & ".xls]Sheet1!$S$45"
ActiveCell.Copy
ActiveCell.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Offset(1, 0).Select
Kx = Kx + 1
Cells(Kx, 1).Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End If
fx = Dir()
Loop
End Sub