How, instead of the range "A: I" in the example below, to implement the ability to set its (range) by hand, by selecting the mouse through the columns of the desired area?

Sub xxx() ActiveSheet.PageSetup.PrintArea = "A:I" With ActiveSheet.PageSetup .CenterHorizontally = True .CenterVertically = False .Orientation = xlLandscape .Zoom = 100 .ScaleWithDocHeaderFooter = True .AlignMarginsHeaderFooter = False End With End Sub 

    2 answers 2

    Use the InputBox to manually enter a range.

     Sub PrintRange() Dim r As Range Set r = Application.InputBox("Выдедить диапазон печати", "ВЫБОР", Type:=8) ActiveSheet.PageSetup.PrintArea = r.Address '..................... End Sub 
    • Fine! Thank. - Dmitry Kutyrkin

    This code selects the area selected by the mouse for printing.

     Sub xxx() ActiveSheet.PageSetup.PrintArea = Selection.Address With ActiveSheet.PageSetup .CenterHorizontally = True .CenterVertically = False .Orientation = xlLandscape .Zoom = 100 .ScaleWithDocHeaderFooter = True .AlignMarginsHeaderFooter = False End With End Sub 
    • Thank you very much this is exactly what I asked for, but vikttur suggested a more visual option. - Dmitry Kutyrkin
    • it seems to me that you did not mark the answer as accepted, and this will mislead visitors looking for "how to set the range by clicking on the mouse" - KAGG Design
    • I slightly corrected the content of the question so that it corresponded to my choice of the correct answer, thank you again! - Dmitry Kutyrkin
    • Of course, it's up to you - KAGG Design