I get a 1004 error on the advanced filtering but if I use the same code as a separate macro in the new file it works fine
Any ideas?
Private Sub reconsheets_Click()
Dim kcode As String
Dim Practice As String
Application.DisplayAlerts = False
x = 1
With Application
.EnableEvents = False
.ScreenUpdating = False
Do While Cells(x, 1) <> ""
kcode = Cells(x, 1)
Practice = Cells(x, 2)
ActiveWorkbook.SaveCopyAs Filename:="S:\Primary Care\berks east ES 12-13\reconciliations\" & kcode & " - " & Practice & ".xls"
Workbooks.Open Filename:= _
"S:\Primary Care\berks east ES 12-13\reconciliations\" & kcode & " - " & Practice & ".xls", UpdateLinks:=0
Sheets("reconciliation sheet").Select
Worksheets("reconciliation sheet").Range("A3").Value = Practice
Worksheets("reconciliation sheet").Range("B3").Value = kcode
Sheets("payments").Select
Range("A1:D4328").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets _
("Reconciliation sheet").Range("B2:B3"), CopyToRange:=Range("I1:L250"), Unique:=False
ActiveWorkbook.Save
ActiveWorkbook.Close
x = x + 1
Loop
.EnableEvents = True
.ScreenUpdating = True
Application.DisplayAlerts = True
End With
MsgBox "Reconciliation sheets have now been created", vbInformation
End Sub
Bookmarks