I have a sub that prepares a sheet to be printed. Several sheets share this sub, as they all need to have the same Print Area, etc. This sub gets called each time one of the sheets needs to be printed. I've run across a problem that only happens when I'm stepping through my code.
Here's the chunk of code in question.
If I run the code normally, it works fine. However, if I'm stepping through the code, after the .Zoom = False line, I get the following message on Excel:
The number must be between 10 and 400. Try again by entering a number in this range.
(I believe I found this code on this forum somewhere a few months back and adjusted it to fit my needs. So I'm not 100% sure if the line with the .Zoom = False is necessary, but I assume it is since it was in the code example I found here.)
I don't understand why this code works fine when it's run normally, but gives this message when I'm stepping through it. Any ideas?
Here's the chunk of code in question.
Code:
PrintAreaRange = "C4:" & LastColumnLetter & "213"
With ThisWorkbook.Sheets(SheetName).PageSetup
.PrintArea = Range(PrintAreaRange).Address
.Orientation = xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintTitleRows = "$4:$9"
End With
If I run the code normally, it works fine. However, if I'm stepping through the code, after the .Zoom = False line, I get the following message on Excel:
The number must be between 10 and 400. Try again by entering a number in this range.
(I believe I found this code on this forum somewhere a few months back and adjusted it to fit my needs. So I'm not 100% sure if the line with the .Zoom = False is necessary, but I assume it is since it was in the code example I found here.)
I don't understand why this code works fine when it's run normally, but gives this message when I'm stepping through it. Any ideas?