'Option Explicit
'Public iLastRow As Long
Const FIRST_ROW& = 1
Sub CreatePageSubtotals5555()
Dim iPageNum&, viewState, hpb As HPageBreak, iRow1&, iRow2&
Dim lLastRow As Long
Dim Ws As Worksheet
Set Ws = Sheets("Реестр от __.__.____")
viewState = ActiveWindow.View
ActiveWindow.View = xlPageBreakPreview
iRow1 = FIRST_ROW
For Each hpb In ActiveSheet.HPageBreaks
iPageNum = iPageNum + 1
'iRow2 = hpb.Location.Row - 9
lLastRow = hpb.Location.Row - 9
Rows(lLastRow).Resize(9).Insert
''-------------------------------------
'' ПОДВАЛ
Range(Ws.Cells(lLastRow - 1, 1), Ws.Cells(lLastRow - 1, 6)).Borders(xlEdgeBottom).Weight = xlMedium
Range(Ws.Cells(lLastRow, 1), Ws.Cells(lLastRow + 8, 6)).Clear
Ws.Cells(lLastRow + 3, 2) = "СДАЛ:"
Ws.Cells(lLastRow + 3, 2).Font.Bold = True
Ws.Cells(lLastRow + 3, 3).Borders(xlEdgeBottom).Weight = xlThin
Range(Ws.Cells(lLastRow + 3, 4), Ws.Cells(lLastRow + 3, 5)).Merge
Range(Ws.Cells(lLastRow + 3, 4), Ws.Cells(lLastRow + 3, 5)).HorizontalAlignment = xlCenter
Range(Ws.Cells(lLastRow + 3, 4), Ws.Cells(lLastRow + 3, 5)).Font.Bold = True
Range(Ws.Cells(lLastRow + 3, 4), Ws.Cells(lLastRow + 3, 5)).Value = "ПРИНЯЛ:"
Ws.Cells(lLastRow + 3, 6).Borders(xlEdgeBottom).Weight = xlThin
Ws.Cells(lLastRow + 4, 3) = "(подпись)"
Ws.Cells(lLastRow + 4, 3).HorizontalAlignment = xlCenter
Ws.Cells(lLastRow + 4, 3).Font.Size = 7
Ws.Cells(lLastRow + 4, 3).VerticalAlignment = xlTop
Ws.Cells(lLastRow + 4, 6) = "бригадир"
Ws.Cells(lLastRow + 4, 6).HorizontalAlignment = xlCenter
Ws.Cells(lLastRow + 4, 6).Font.Size = 7
Ws.Cells(lLastRow + 4, 6).VerticalAlignment = xlTop
Ws.Cells(lLastRow + 6, 3) = "М.П."
Ws.Cells(lLastRow + 6, 6).Borders(xlEdgeBottom).Weight = xlThin
Ws.Cells(lLastRow + 7, 6) = "контролер"
Ws.Cells(lLastRow + 7, 6).HorizontalAlignment = xlCenter
Ws.Cells(lLastRow + 7, 6).Font.Size = 7
Ws.Cells(lLastRow + 7, 6).VerticalAlignment = xlTop
Range(Ws.Cells(lLastRow + 7, 3), Ws.Cells(lLastRow + 7, 6)).Borders(xlEdgeBottom).Weight = xlMedium
Ws.Cells(lLastRow + 8, 3) = "Примечание:"
Ws.Cells(lLastRow + 8, 3).Font.Bold = True
Ws.Cells(lLastRow + 8, 3).Font.Color = RGB(191, 191, 191)
Range(Ws.Cells(lLastRow + 8, 4), Ws.Cells(lLastRow + 8, 6)).Merge
Range(Ws.Cells(lLastRow + 8, 4), Ws.Cells(lLastRow + 8, 6)).Borders(xlEdgeBottom).Weight = xlMedium
Range(Ws.Cells(lLastRow + 8, 4), Ws.Cells(lLastRow + 8, 6)).Borders.Color = RGB(191, 191, 191)
''----------------------------------------------------
' Cells(iRow2, ITOGO_COL) = "Итого по странице " & iPageNum & ":"
' Range(Cells(iRow2, FIRST_COL), Cells(iRow2, LAST_COL)).FormulaR1C1 = _
' "=SUBTOTAL(9,R[" & iRow1 - iRow2 & "]C:R[-1]C)"
' Rows(iRow2).Font.Bold = True
iRow1 = lLastRow '+ 9
Next
'iRow2 = Cells(Rows.Count, FIRST_COL).End(xlUp).Row + 1
lLastRow = Cells(Rows.Count, 1).End(xlUp).Row '+ 9 'hpb.Location.Row - 9
ActiveWindow.View = viewState
End Sub |