Print button (B4:D103)

jimjaix

Board Regular
Joined
Mar 11, 2009
Messages
58
Hi, I want to create a print button to print some cells. let's say B4:D104 and another button to print B105:D194. Is it possible?

I LOVE THIS WEBSITE!!!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
For your first button try

Code:
Sub PrtRng1()
With ActiveSheet
    .PageSetup.PrintArea = "B4:D106"
    .PrintOut
End With
End Sub

The code for the second button should be obvious.
 
Upvote 0
Hi I used the same code you provided beside the name, I changed to the command button name it assigned. When i click on the button nothing happens, no error message no print out nothing?



For your first button try

Code:
Sub PrtRng1()
With ActiveSheet
    .PageSetup.PrintArea = "B4:D106"
    .PrintOut
End With
End Sub

The code for the second button should be obvious.
 
Upvote 0
Well, this works for me

Code:
Private Sub CommandButton1_Click()
With ActiveSheet
    .PageSetup.PrintArea = "B4:D106"
    .PrintOut
End With
End Sub

Make sure that you have exited Design Mode after creating the button and make sure that macros are enabled.
 
Upvote 0
Hi Thanks, I got it to work now. I forgot I already have a Button1, I needed to change it to 2.


Well, this works for me

Code:
Private Sub CommandButton1_Click()
With ActiveSheet
    .PageSetup.PrintArea = "B4:D106"
    .PrintOut
End With
End Sub

Make sure that you have exited Design Mode after creating the button and make sure that macros are enabled.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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