Hello,
I received this Print Macro from a board member but its printing all the sheets in my spreadsheet I have sheet named "Admin" which is the only one I want to print out with these rules applied below:
What would be the macro to print a sheet for cells A1 thru J216?
but only print data thru cells A21 thru J129 and if there is no data in those cells then it wouldnt print those rows
but it still needs to print cells below it J130 thru J216 and above A20.
the worksheet name is "Admin"
Thanks,
Eric
code:
--------------------------------------------------------------------------------
Sub Macro1()
Dim strOrigPrintArea As String
Dim shtSource As Worksheet, shtTemp As Worksheet
Dim iRow As Integer, iTotal As Integer
Application.ScreenUpdating = False
Set shtSource = Sheets("Admin")
strOrigPrintArea = shtSource.PageSetup.PrintArea
shtSource.PageSetup.PrintArea = ""
Set shtTemp = Worksheets.Add
shtSource.Range("A1:J216").Copy
ActiveSheet.Paste
iRow = 1
iTotal = 129
Do While iRow <= iTotal And iRow >= 1
If Range("J" & iRow) = "" And Range("J" & iRow).End(xlToLeft).Column = 1 And Range("A" & iRow) = "" Then
Rows(iRow).Delete
iTotal = iTotal - 1
Else
iRow = iRow + 1
End If
Loop
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$" & iTotal + 216 - 130 + 1
ActiveWorkbook.PrintOut
Application.DisplayAlerts = False
shtTemp.Delete
Application.DisplayAlerts = True
shtSource.PageSetup.PrintArea = strOrigPrintArea
Application.ScreenUpdating = True
End Sub
I received this Print Macro from a board member but its printing all the sheets in my spreadsheet I have sheet named "Admin" which is the only one I want to print out with these rules applied below:
What would be the macro to print a sheet for cells A1 thru J216?
but only print data thru cells A21 thru J129 and if there is no data in those cells then it wouldnt print those rows
but it still needs to print cells below it J130 thru J216 and above A20.
the worksheet name is "Admin"
Thanks,
Eric
code:
--------------------------------------------------------------------------------
Sub Macro1()
Dim strOrigPrintArea As String
Dim shtSource As Worksheet, shtTemp As Worksheet
Dim iRow As Integer, iTotal As Integer
Application.ScreenUpdating = False
Set shtSource = Sheets("Admin")
strOrigPrintArea = shtSource.PageSetup.PrintArea
shtSource.PageSetup.PrintArea = ""
Set shtTemp = Worksheets.Add
shtSource.Range("A1:J216").Copy
ActiveSheet.Paste
iRow = 1
iTotal = 129
Do While iRow <= iTotal And iRow >= 1
If Range("J" & iRow) = "" And Range("J" & iRow).End(xlToLeft).Column = 1 And Range("A" & iRow) = "" Then
Rows(iRow).Delete
iTotal = iTotal - 1
Else
iRow = iRow + 1
End If
Loop
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$" & iTotal + 216 - 130 + 1
ActiveWorkbook.PrintOut
Application.DisplayAlerts = False
shtTemp.Delete
Application.DisplayAlerts = True
shtSource.PageSetup.PrintArea = strOrigPrintArea
Application.ScreenUpdating = True
End Sub