'================================================================================
' ##### изменение внешних границ печати
'!!!!!нельзя одновременно изменить оба измерения границ печати
Function FnPrintArea()
On Error Resume Next
strDelim = "$"
strPrintArea = ActiveSheet.PageSetup.PrintArea
iNbRowEnd = Columns(2).Rows(Rows.Count).End(xlUp).Row
m = Split(strPrintArea, strDelim, -1, vbTextCompare)
' 1. выравниваем по столбцу
strPrintArea = strDelim & m(1) & strDelim & m(2) & strDelim & "E" & strDelim & m(4)
ActiveSheet.PageSetup.PrintArea = strPrintArea
' 2. выравниваем по строке
strPrintArea = strDelim & m(1) & strDelim & m(2) & strDelim & "E" & strDelim & iNbRowEnd
ActiveSheet.PageSetup.PrintArea = strPrintArea
'ActiveSheet.PageSetup.PrintArea = "$A$1:$E$9" & iNbRowEnd
'ActiveSheet.HPageBreaks(1).DragOff Direction:=xlDown, RegionIndex:=1
End Function
'================================================================================