Good day to all.
I have the bellow code, but urgenlty need a little ammendment. Now it is printing out, but would like to save in PDF (in defined directory) with name from column J.
Sub forfiett()
Dim i As Long, printrange As Range, x As Long, y As Long
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationAutomatic
End With
For i = Range("J" & Rows.Count).End(3).row To 1 Step -1
If Cells(i, "J") <> Cells(i + 1, "J") Then
Rows(i + 1).Resize(2).Insert
End If
Next i
For Each printrange In Range("J2:J" & Range("J" & Rows.Count).End(3).row + 1).SpecialCells(2, 2).Areas
x = printrange.Cells(1, 1).row
y = printrange.Cells(1, 1).End(4).row
If Cells(x + 1, "C") = "" Then y = y - 2
If y >= x + 2 Then
With ActiveSheet.PageSetup
.PrintArea = Range(Cells(x, "A"), Cells(y, "AE")).Address
.Orientation = xlLandscape
.PrintTitleRows = "$1:$1"
End With
ActiveWindow.SelectedSheets.PrintOut copies:=1
Else
y = x + 1
With ActiveSheet.PageSetup
.PrintArea = Range(Cells(x, "A"), Cells(y, "AE")).Address
.Orientation = xlLandscape
.PrintTitleRows = "$1:$1"
End With
ActiveWindow.SelectedSheets.PrintOut copies:=1
End If
Next printrange
Range("J2:J" & Range("J" & Rows.Count).End(3).row).SpecialCells(4).EntireRow.Delete
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.Calculation = xlCalculationManual
End With
End Sub
Bookmarks