Print Macro Button

Emb21

Board Regular
Joined
Jul 8, 2004
Messages
152
Hello,

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.

the worksheet name is "Admin"

Thanks, :biggrin:
Eric
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Something like this?

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
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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