ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Print Button with Criteria (https://www.excelbanter.com/excel-discussion-misc-queries/178103-print-button-criteria.html)

KC

Print Button with Criteria
 
I have a tab in my workbook that I want to print with a print button.
However, it needs to print depending on certain criteria. Such as, if Cell
E6 = "SMB" then print A1:P39, if Cell E6 = "KRT" then print A1:R39, if Cell
E6 = "BRS" then print A1:T39. Is it possible to do this?

Gord Dibben

Print Button with Criteria
 
You could do this without a macro.

Just create 3 Custom Views with different print settings.

ViewCustom Views

Or a macro for your button.

Sub print_cases()
With ActiveSheet
Select Case Range("E6")
Case "SMB"
.PageSetup.PrintArea = "$A$1:$P$39"
.PrintOut
Case "KRT"
.PageSetup.PrintArea = "$A$1:$F$39"
.PrintOut
Case "BRS"
.PageSetup.PrintArea = "$A$1:$T$39"
.PrintOut
End Select
End With
End Sub


Gord Dibben MS Excel MVP

On Wed, 27 Feb 2008 12:58:00 -0800, KC wrote:

I have a tab in my workbook that I want to print with a print button.
However, it needs to print depending on certain criteria. Such as, if Cell
E6 = "SMB" then print A1:P39, if Cell E6 = "KRT" then print A1:R39, if Cell
E6 = "BRS" then print A1:T39. Is it possible to do this?




All times are GMT +1. The time now is 03:01 PM.

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