ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Print macro help (https://www.excelbanter.com/excel-programming/392575-print-macro-help.html)

ADK

Print macro help
 
macro beginner


I have the following set to a command button to print. So far the macro sets
the print area perfectly the way I want it. I just need to know what is
missing after the print area is defined to actually send it to the printer

Private Sub CommandButton1_Click()
Worksheets("PDSR").Activate
Set c = Worksheets("PDSR").Columns("Y"). _
Find("0", LookIn:=xlValues)
If Not c Is Nothing Then
Worksheets("PDSR").Range(Cells(1, 1), Cells(c.Row, 12)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
End If
End Sub



jayray

Print macro help
 
On Jul 3, 8:49 am, "ADK" wrote:
macro beginner

I have the following set to a command button to print. So far the macro sets
the print area perfectly the way I want it. I just need to know what is
missing after the print area is defined to actually send it to the printer

Private Sub CommandButton1_Click()
Worksheets("PDSR").Activate
Set c = Worksheets("PDSR").Columns("Y"). _
Find("0", LookIn:=xlValues)
If Not c Is Nothing Then
Worksheets("PDSR").Range(Cells(1, 1), Cells(c.Row, 12)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
End If
End Sub



A good way to find out what the macro needs to do is to go through the
steps manually while recording a macro. In this case, you'll be able
to see what the command for sending the range to the printer will be.


ADK

Print macro help
 
thanks

"jayray" wrote in message
ups.com...
On Jul 3, 8:49 am, "ADK" wrote:
macro beginner

I have the following set to a command button to print. So far the macro
sets
the print area perfectly the way I want it. I just need to know what is
missing after the print area is defined to actually send it to the
printer

Private Sub CommandButton1_Click()
Worksheets("PDSR").Activate
Set c = Worksheets("PDSR").Columns("Y"). _
Find("0", LookIn:=xlValues)
If Not c Is Nothing Then
Worksheets("PDSR").Range(Cells(1, 1), Cells(c.Row, 12)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
End If
End Sub



A good way to find out what the macro needs to do is to go through the
steps manually while recording a macro. In this case, you'll be able
to see what the command for sending the range to the printer will be.




Don Guillett

Print macro help
 
This will do it from anywhere in the workbook, withOUT selections. Pay
attention to the . s in the with statement.

Sub printrng()
With Sheets("PDSR")
lr = .Columns("y").Find(0).row
..Range(Cells(1, 1), Cells(lr, 12)).Printout 'Preview
End With
End Sub

--
Don Guillett Excel MVP
SalesAid Software

"ADK" wrote in message
...
macro beginner


I have the following set to a command button to print. So far the macro
sets the print area perfectly the way I want it. I just need to know what
is missing after the print area is defined to actually send it to the
printer

Private Sub CommandButton1_Click()
Worksheets("PDSR").Activate
Set c = Worksheets("PDSR").Columns("Y"). _
Find("0", LookIn:=xlValues)
If Not c Is Nothing Then
Worksheets("PDSR").Range(Cells(1, 1), Cells(c.Row, 12)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
End If
End Sub




All times are GMT +1. The time now is 06:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com