S
Sisilla
Hello All,
I want to set Zoom so that all columns can fit in one page. First, I
sum the widths of the visible columns on the page between A and O and
convert the measurement to inches. I then set the Orientation,
PaperSize and Zoom based on the measurement. I am using the following
code-:
Dim cw As Double
Dim Counter As Long
For Counter = 1 To 15
If
Sheets("Application").Columns(Counter).EntireColumn.Hidden = False
Then
cw = cw + Sheets("Application").Columns(Counter).Width
End If
Next Counter
cw = cw / 72
If cw > 0 And cw <= 8 Then
Sheets("Application").PageSetup.Orientation = xlPortrait
Sheets("Application").PageSetup.PaperSize = xlPaperLetter
Sheets("Application").PageSetup.Zoom =
WorksheetFunction.RoundDown(700 / cw, 0)
Else
If cw > 8 And cw <= 11 Then
Sheets("Application").PageSetup.Orientation =
xlLandscape
Sheets("Application").PageSetup.PaperSize =
xlPaperLetter
Sheets("Application").PageSetup.Zoom =
WorksheetFunction.RoundDown(1000 / cw, 0)
Else
If cw > 11 Then
Sheets("Application").PageSetup.Orientation =
xlLandscape
Sheets("Application").PageSetup.PaperSize =
xlPaperLegal
Sheets("Application").PageSetup.Zoom =
WorksheetFunction.RoundDown(1300 / cw, 0)
End If
End If
End If
If my calculations are correct, this code should work fine, but I have
been encountering problems. When cw = 14.76 inches, for example, the
zoom is 88%, but this zoom results in the last column being printed in
a spearate sheet. Theoretically, this Zoom should work since 88% of
14.76 is 13, so all the columns should fit fine on a legal-sized,
landscape-oriented page, but maybe I am not understanding clearly how
Zoom works.
I should note that the left and right margins have been set to zero.
What am I doing wrong here? I appreciate any effort to help me. Thank
you for your time and consideration.
Sincerely,
Sisilla
I want to set Zoom so that all columns can fit in one page. First, I
sum the widths of the visible columns on the page between A and O and
convert the measurement to inches. I then set the Orientation,
PaperSize and Zoom based on the measurement. I am using the following
code-:
Dim cw As Double
Dim Counter As Long
For Counter = 1 To 15
If
Sheets("Application").Columns(Counter).EntireColumn.Hidden = False
Then
cw = cw + Sheets("Application").Columns(Counter).Width
End If
Next Counter
cw = cw / 72
If cw > 0 And cw <= 8 Then
Sheets("Application").PageSetup.Orientation = xlPortrait
Sheets("Application").PageSetup.PaperSize = xlPaperLetter
Sheets("Application").PageSetup.Zoom =
WorksheetFunction.RoundDown(700 / cw, 0)
Else
If cw > 8 And cw <= 11 Then
Sheets("Application").PageSetup.Orientation =
xlLandscape
Sheets("Application").PageSetup.PaperSize =
xlPaperLetter
Sheets("Application").PageSetup.Zoom =
WorksheetFunction.RoundDown(1000 / cw, 0)
Else
If cw > 11 Then
Sheets("Application").PageSetup.Orientation =
xlLandscape
Sheets("Application").PageSetup.PaperSize =
xlPaperLegal
Sheets("Application").PageSetup.Zoom =
WorksheetFunction.RoundDown(1300 / cw, 0)
End If
End If
End If
If my calculations are correct, this code should work fine, but I have
been encountering problems. When cw = 14.76 inches, for example, the
zoom is 88%, but this zoom results in the last column being printed in
a spearate sheet. Theoretically, this Zoom should work since 88% of
14.76 is 13, so all the columns should fit fine on a legal-sized,
landscape-oriented page, but maybe I am not understanding clearly how
Zoom works.
I should note that the left and right margins have been set to zero.
What am I doing wrong here? I appreciate any effort to help me. Thank
you for your time and consideration.
Sincerely,
Sisilla