Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Function CellsExistOutsidePrintArea(ByVal Wks As Worksheet) As Boolean
With Wks
CellsExistOutsidePrintArea = .UsedRange.Count > .Range(.PageSetup.PrintArea).Count
End With
End Function
Function GetCellsOutsidePrintArea(ByVal Wks As Worksheet) As Range
Dim PrintRng As Range
Dim OneCell As Range
Dim ResultRng As Range
With Wks
Set PrintRng = .Range(.PageSetup.PrintArea)
For Each OneCell In .UsedRange
If OneCell.Value <> "" Then
If Application.Intersect(OneCell, PrintRng) Is Nothing Then
If ResultRng Is Nothing Then
Set ResultRng = OneCell
Else
Set ResultRng = Application.Union(ResultRng, OneCell)
End If
End If
End If
Next OneCell
End With
Set GetCellsOutsidePrintArea = ResultRng
End Function
Sub tester()
Dim UsedRng As Range, PrintRng As Range, iSect As Range
Set UsedRng = ActiveSheet.UsedRange
Set PrintRng = Range(ActiveSheet.PageSetup.PrintArea)
Set iSect = Intersect(UsedRng, PrintRng)
If iSect.Address <> UsedRng.Address Then
MsgBox "Data outside of Print Area"
Else
End If
End Sub