PDA

View Full Version : Landscape and Portrait format at the same sheet



gcduarte
10-24-2013, 11:37 AM
I d' like to know if anybody can help me. The question is simple: I have a Excel sheet and I want to print this sheet in landscape and portrait format depends on the number of the columns, like it, if the information use 10 columns I will print in landscape format, if less in portrait. Thanks a lot. I win to print in different pages but in a same not. I don't know if is possible do it in Excel.

mikerickson
10-24-2013, 11:17 PM
You could put this in the ThisWorkbook code module.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
With Sh
If .UsedRange.Columns.Count < 10 Then
.PageSetup.Orientation = xlPortrait
Else
.PageSetup.Orientation = xlLandscape
End If
End With
End Sub

gcduarte
10-25-2013, 05:21 AM
You could put this in the ThisWorkbook code module.


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
With Sh
If .UsedRange.Columns.Count < 10 Then
.PageSetup.Orientation = xlPortrait
Else
.PageSetup.Orientation = xlLandscape
End If
End With
End Sub

Dear mikerickson. I need to say thanks a lot about your help. I will try to use your code in my challenge. Regards.