G
Guest
Using XL 2003 & 97
The MyLastRow and MylastColumn variables are not resetting for each worksheet.
My goal is to set the print range of each worksheet to the used range.
What Am I doing wrong?
What is happening. is that every sheet's print range is set to the UsedRange
of the first sheet.
Sub Test()
Dim EachSheet As Worksheet
Dim myLastRow As Long, myLastCol As Long
For Each EachSheet In ActiveWorkbook.Worksheets
With EachSheet.PageSetup
myLastRow = Cells(Rows.Count, 1).End(xlUp).Row
myLastCol = Cells.SpecialCells(xlLastCell).Column
.PrintArea = ""
.PrintArea = Range(Cells(1, 1), Cells(myLastRow, myLastCol)).Address
.......................
End With
Next EachSheet
End Sub
The MyLastRow and MylastColumn variables are not resetting for each worksheet.
My goal is to set the print range of each worksheet to the used range.
What Am I doing wrong?
What is happening. is that every sheet's print range is set to the UsedRange
of the first sheet.
Sub Test()
Dim EachSheet As Worksheet
Dim myLastRow As Long, myLastCol As Long
For Each EachSheet In ActiveWorkbook.Worksheets
With EachSheet.PageSetup
myLastRow = Cells(Rows.Count, 1).End(xlUp).Row
myLastCol = Cells.SpecialCells(xlLastCell).Column
.PrintArea = ""
.PrintArea = Range(Cells(1, 1), Cells(myLastRow, myLastCol)).Address
.......................
End With
Next EachSheet
End Sub