Private Function IsRangeInPage(sRangeOne As String, sRangeTwo As String, ws As Object) As Boolean
'
On Error GoTo eRes
'//////////////////////////////////////////////////////////////////////////////////////
Dim j As Long
Dim bIsSame As Boolean, lRangeOneRow As Long, lRangeTwoRow As Long
Dim lPageBreakRow As Long
Dim lPagePrevBreakRow As Long
'//////////////////////////////////////////////////////////////////////////////////////
If ws.HPageBreaks.Count = 0 Then
IsRangeInPage = True
Exit Function
End If
lRangeOneRow = ws.Range(sRangeOne).Row
lRangeTwoRow = ws.Range(sRangeTwo).Row
lPageBreakRow = ws.HPageBreaks(1).Location.Row
If lRangeOneRow < lPageBreakRow And lRangeTwoRow < lPageBreakRow Then
IsRangeInPage = True
Exit Function
End If
bIsSame = False
For j = 2 To ws.HPageBreaks.Count
lPageBreakRow = ws.HPageBreaks(j).Location.Row
lPagePrevBreakRow = ws.HPageBreaks(j - 1).Location.Row
If lRangeOneRow < lPageBreakRow And _
lRangeTwoRow < lPageBreakRow And _
lRangeOneRow > lPagePrevBreakRow And _
lRangeTwoRow > lPagePrevBreakRow Then
bIsSame = True
Exit For
End If
Next
IsRangeInPage = bIsSame
Exit Function
eRes:
Call Err.Raise(Err.Number, "IsRangeInPage", Err.Description)
End Function
HPageBreaks.Add Before:=.Range(<имя диапазона>)
Сейчас этот форум просматривают: Google-бот и гости: 69