Printing three areas per page

Gizmo-helten

New Member
Joined
Sep 17, 2006
Messages
9
I have a sheet where information can be put in 20 areas. An area covers 19 rows and if there is put data in one of the areas it should be printed. I can put three areas in a single A4-page. The problem is that when I press the print button in the toolbar it prints the entire sheet, and I have tried experimenting with a macro that should check for which areas that are data in and print them out. But I can´t get it to work, can anyone please help me???
My printOut code looks like this, but nothing happens at all???
This first area is an area that calculates all the areas together, and should be put alone on the first printed page...

If I54 > "" Then
Range("$C$10:$J$32").Select
Selection.PrintOut
End If

If I54 > 0 Then
Range("$C$35:$J$54").Select
Selection.PrintOut
End If

If I75 > 0 Then
Range("$C$56:$J$75").Select
Selection.PrintOut
End If

If I96 > 0 Then
Range("$C$98:$J$117").Select
Selection.PrintOut
End If

And so it continous 20 times

I also have tried this code:

Private Sub CommandButton2_Click()

If I36 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J54").PrintOut

ElseIf I58 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J78").PrintOut

ElseIf I79 > 0 Then
Worksheets("Dagseddel").Activate
Worksheets("Dagseddel").Range("C10:J97").PrintOut


End If
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try like this

Code:
Sub tst()
If Range("I54").Value > "" Then
Range("$C$10:$J$32").PrintOut
End If
End Sub
 
Upvote 0
Try like this

Code:
Sub tst()
If Range("I54").Value > "" Then
Range("$C$10:$J$32").PrintOut
End If
End Sub

YES!!! It worked just like I wanted it to :LOL:
Thank you very much for your help....
I modified it to this:

Private Sub CommandButton2_Click()

'side1:
If Range("I54").Value > 0 Then
Range("$C$10:$J$32").PrintOut
End If
'side2:
If Range("I96").Value > 0 Then
Range("$C$35:$J$96").PrintOut

ElseIf Range("I75").Value > 0 Then
Range("$C$35:$J$75").PrintOut

ElseIf Range("I54").Value > 0 Then
Range("$C$35:$J$54").PrintOut
'side3:
ElseIf Range("I159").Value > 0 Then
Range("$C$98:$J$159").PrintOut

ElseIf Range("I138").Value > 0 Then
Range("$C$98:$J$138").PrintOut

ElseIf Range("I117").Value > 0 Then
Range("$C$98:$J$117").PrintOut
'side4:
ElseIf Range("I222").Value > 0 Then
Range("$C$161:$J$222").PrintOut

ElseIf Range("I201").Value > 0 Then
Range("$C$161:$J$201").PrintOut

ElseIf Range("I180").Value > 0 Then
Range("$C$161:$J$180").PrintOut
'side5:
ElseIf Range("I285").Value > 0 Then
Range("$C$224:$J$285").PrintOut

ElseIf Range("I264").Value > 0 Then
Range("$C$224:$J$264").PrintOut

ElseIf Range("I243").Value > 0 Then
Range("$C$224:$J$243").PrintOut
'side6:
ElseIf Range("I348").Value > 0 Then
Range("$C$287:$J$348").PrintOut

ElseIf Range("I327").Value > 0 Then
Range("$C$287:$J$327").PrintOut

ElseIf Range("I306").Value > 0 Then
Range("$C$287:$J$306").PrintOut
'side7:
ElseIf Range("I411").Value > 0 Then
Range("$C$350:$J$411").PrintOut

ElseIf Range("I390").Value > 0 Then
Range("$C$350:$J$390").PrintOut

ElseIf Range("I369").Value > 0 Then
Range("$C$350:$J$369").PrintOut
'side8:
ElseIf Range("I453").Value > 0 Then
Range("$C$413:$J$453").PrintOut

ElseIf Range("I432").Value > 0 Then
Range("$C$413:$J$432").PrintOut

End If

End Sub


So it prints out the first area 'side1(page1) and if the other areas are filled it prints them out, and it fits with three areas per page :)
Thanks again
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,543
Latest member
MartinLarkin

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