Sub Deactivator()
On Error Resume Next
Const Str1 = "Deactivate"
Dim strPA As String
Dim rng As Range, rngPA As Range
With ActiveSheet
strPA = .PageSetup.PrintArea
If strPA = "" Then
If vbYes = MsgBox("No Print Area is defined. Set it to UsedRange?", vbYesNo) Then
strPA = .UsedRange.Address
.PageSetup.PrintArea = strPA
Else
GoTo EP
End If
End If
Set rngPA = .Range(strPA)
Set rng = .Range("A:A").Find(Str1)
If rng Is Nothing Then MsgBox "No " & Str1 & " lines found.": GoTo EP
If rng.Row <= rngPA.Row Then
.PageSetup.PrintArea = ""
MsgBox "Print Area is cleared."
GoTo EP
End If
Set rngPA = rngPA.Resize(rng.Row - rngPA.Row)
.PageSetup.PrintArea = rngPA.Address
End With
EP:
Set rng = Nothing
Set rngPA = Nothing
End Sub