print or no print /landscape

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
667
Office Version
  1. 365
Platform
  1. Windows
hi

VBA Code:
Sub rotasort()
'
' rotasort Macro
'

'
    Columns("A:C").Select
    Selection.EntireColumn.Hidden = True
    Range("D3:AI21").Select
    ActiveSheet.PageSetup.PrintArea = "$D$3:$AI$21"
    Range("AK23").Select
    Columns("D:D").ColumnWidth = 19.14
    Columns("D:D").ColumnWidth = 17.57
    Columns("D:D").ColumnWidth = 15
    Columns("D:D").Select
    With Selection
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("D3:AI22").Select
    ActiveSheet.PageSetup.PrintArea = ""
    ActiveSheet.PageSetup.PrintArea = "$D$3:$AI$22"
    ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
        :=True, IgnorePrintAreas:=False
End Sub

i use the above, but would like to place a 'yes / no' to print or not & want it to print out landscapetoo..
can some kind person sort for me?

thank you.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try this (I cleaned up your code a little too):
VBA Code:
Sub rotasort()
'
' rotasort Macro
'

    Dim prt

    Columns("A:C").EntireColumn.Hidden = True

    With Columns("D:D")
        .ColumnWidth = 15
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With

    With ActiveSheet.PageSetup
        .PrintArea = "$D$3:$AI$22"
        .Orientation = xlLandscape
    End With
    
    prt = MsgBox("Do you wish to print the sheet now?", vbYesNo)
    If prt = vbYes Then
        ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
            :=True, IgnorePrintAreas:=False
    End If
    
End Sub
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0
You are welcome.
Glad I was able to help!
Your help has alwas been very, very much apprecaited & I am sure it will continue to do so.
as are all the other kind 'mr excel's'
 
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top