Here what could be done
go step by step to see what's happening
Option Explicit
Sub Treat()
Const WsInN1 = "Access"
Const FdN = "client backups 21.02.2020"
Dim Ws1 As Worksheet
Set Ws1 = Sheets(WsInN1)
Dim ClientDic As Object
Set ClientDic = CreateObject("Scripting.Dictionary")
Dim WkRg As Range, Rg As Range
Dim K
Dim WkPh As String
WkPh = ActiveWorkbook.Path & "\" & FdN
Application.ScreenUpdating = False
With Ws1
.AutoFilterMode = False
For Each Rg In Range(.Cells(2, "B"), .Cells(Rows.Count, "B").End(3)(2))
If (Rg <> "") Then ClientDic.Item(Rg.Value) = Empty
Next Rg
Set WkRg = .Cells(1, 1).CurrentRegion
For Each K In ClientDic.keys
Workbooks.Add
With WkRg
.AutoFilter Field:=2, Criteria1:=K
.SpecialCells(xlCellTypeVisible).Copy Destination:=Cells(1, 1)
End With
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=WkPh & "\" & K & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
ActiveWorkbook.Close SaveChanges:=False ' Quit without saving
Next K
.AutoFilterMode = False
End With
Application.ScreenUpdating = True
MsgBox ("Job Done")
End Sub
Bookmarks