Print Macro

davidhall

Board Regular
Joined
Mar 6, 2011
Messages
174
I have data that appears from Cell B83 to Z147. The entire area isn't always populated and information filters into this area based on other criteria. In column A, I have 0's and 1's which acts as the filtering mechanism. Any row with a 0 in it remains hidden. Any row with a 1 is visible. My filtering mechanism does apply to other contents above row 83 but I only need the data within the range mentioned above to print.

The button I am assinging this macro to needs to fit the data to the page and print to my printer named PDFCreator.

Any suggestions?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Something along these lines may work:

Code:
Private Sub CommandButton1_Click()
 
ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:="1"
 
With ActiveSheet.PageSetup
    .PrintArea = "C83:Z147"
    .Zoom = False
    .FitToPagesTall = 1
    .FitToPagesWide = 1
End With
 
ActiveSheet.PrintOut ActivePrinter:="PDFCreator"
 
End Sub
 
Upvote 0
One more quick question. If I wanted the print function to ignore the data in the range of D83 to G147 but print everything else in the initial range of B83 to Z147, how would I go about doing that?
 
Upvote 0
Code:
Columns("D:G").EntireColumn.Hidden = True
 
' Do stuff
 
Columns("D:G").EntireColumn.Hidden = False
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,916
Members
452,949
Latest member
beartooth91

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