Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Excel set print area onclick

Excel set print area onclick

Excel set print area onclick

Hi guys I returning to this after 15 yrs out and my memory is poor. So any help would be fantastic.

I have a button to select a range and print.

Private Sub cmdbtnPrint_Click()
ActiveSheet.PageSetup.PrintArea = "A3:F21"
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _

End Sub

I need to have the end range as a variable ie F21 needs to look and find the last row to cell 21

RE: Excel set print area onclick

If your table is the ONLY thing on the sheet AND you properly DELETE to remove unused cells beside and beneath your table, then UsedRange can be used.

Alternativly, as long as you have a Proper Table (ONE row of headings, NO empty rows within your table, no other non-table data in cells contiguous with the table) then you can use CurrentRegion.

The latter would be my suggestion..


Private Sub cmdbtnPrint_Click()
ActiveSheet.PageSetup.PrintArea = Selection.Address
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _


glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Excel set print area onclick

thanks guys

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close