Print Macro Help

Status
Not open for further replies.

Emb21

Board Regular
Joined
Jul 8, 2004
Messages
152
Hello,

I received this Print Macros 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



code from another member:

Sub myAdminPrnt()
'

Sheets("Admin").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$216"

With ActiveSheet.PageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperLetter
.FitToPagesWide = 1
.FitToPagesTall = False
End With

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Status
Not open for further replies.

Forum statistics

Threads
1,214,575
Messages
6,120,334
Members
448,956
Latest member
Adamsxl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top