Sub PrintToLastShape()
Dim oShp As Shape
Dim oldPrintHighLeft As String
'Dim oldPrintLowRight As String
Dim i As Integer
Dim j As Integer
Dim x As Integer
Dim y As Integer
i = 1
j = 1
x = 0
y = 0
Application.ScreenUpdating = False
With ActiveSheet
If .PageSetup.PrintArea = "" Then
oldPrintHighLeft = .Cells(1, 1).Address
'oldPrintLowRight = .Cells(1, 1).Address
Else
oldPrintHighLeft = Split(.PageSetup.PrintArea, ":")(0)
'oldPrintLowRight = Split(.PageSetup.PrintArea, ":")(1)
End If
For Each oShp In .Shapes
If oShp.BottomRightCell.Row >= i Then i = oShp.BottomRightCell.Row
If oShp.BottomRightCell.Column >= j Then j = oShp.BottomRightCell.Column
Next
.PageSetup.PrintArea = .Range(oldPrintHighLeft, .Cells(i, j)).Address
x = .VPageBreaks.Count
y = .HPageBreaks.Count
Do While .VPageBreaks.Count = x
j = j + 1
.PageSetup.PrintArea = .Range(oldPrintHighLeft, .Cells(i, j)).Address
Loop
Do While .HPageBreaks.Count = y
i = i + 1
.PageSetup.PrintArea = .Range(oldPrintHighLeft, .Cells(i, j)).Address
Loop
.PageSetup.PrintArea = .Range(oldPrintHighLeft, .Cells(i - 1, j - 1)).Address
.PrintOut
'.PageSetup.PrintArea = .Range(oldPrintHighLeft, oldPrintLowRight).Address
End With
Application.ScreenUpdating = True
End Sub