+ Reply to Thread
Results 1 to 11 of 11

how to make macro button to print page that has the active cell only?

  1. #1
    Registered User
    Join Date
    09-24-2011
    Location
    Yemen
    MS-Off Ver
    365
    Posts
    77

    how to make macro button to print page that has the active cell only?

    i have multiple pages at the same worksheet and i need to put macro button for each page
    how to make this macro print the page which has the active cell
    thanks in advance.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: how to make macro button to print page that has the active cell only?

    Hi meonly,

    Try this, I have to admit I didn't test it well since my free time is limited today, but I believe this should work? You will need to adjust the sheet name in the code to the name of the sheet you are working in.
    Please Login or Register  to view this content.
    Last edited by Arkadi; 01-21-2015 at 05:18 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: how to make macro button to print page that has the active cell only?

    Edit: nevermind, read post incorrectly.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: how to make macro button to print page that has the active cell only?

    stnkynts, I assumed he wanted only a specific page within the worksheet's pages? I really overcomplicated if not, lol.

  5. #5
    Registered User
    Join Date
    09-24-2011
    Location
    Yemen
    MS-Off Ver
    365
    Posts
    77

    Re: how to make macro button to print page that has the active cell only?

    Quote Originally Posted by Arkadi View Post
    Hi meonly,

    Try this, I have to admit I didn't test it well since my free time is limited today, but I believe this should work? You will need to adjust the sheet name in the code to the name of the sheet you are working in.
    Please Login or Register  to view this content.
    thanks for your time i am really gratefuller to you
    i use active sheet instead of sheet name coz i have alot of pages
    but it show error on this line :
    If ws.HPageBreaks(i).Location.Row <= rng.Row Then
    any idea!!!

  6. #6
    Registered User
    Join Date
    09-24-2011
    Location
    Yemen
    MS-Off Ver
    365
    Posts
    77

    Re: how to make macro button to print page that has the active cell only?

    Quote Originally Posted by Arkadi View Post
    stnkynts, I assumed he wanted only a specific page within the worksheet's pages? I really overcomplicated if not, lol.
    yes it is , a specific page (which has active cell)

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: how to make macro button to print page that has the active cell only?

    I don't get an error with Arkadi's code, it seems to be fairly sound. Here is another way of doing the same (Arkadi's code is actually a little more encompassing but may be more than you need)

    Please Login or Register  to view this content.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: how to make macro button to print page that has the active cell only?

    Thanks stnkynts
    I could not figure out the reason for the error, I don't get it either when I try. I did not fully test, but did run the macro a few times without error. That said, I don't think I tried it when the sheet is completely empty...

  9. #9
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: how to make macro button to print page that has the active cell only?

    Stnkynts any time you see flaws or inefficient code from me, I'm always happy to hear about it, love to learn

  10. #10
    Registered User
    Join Date
    09-24-2011
    Location
    Yemen
    MS-Off Ver
    365
    Posts
    77

    Re: how to make macro button to print page that has the active cell only?

    Quote Originally Posted by Arkadi View Post
    Thanks stnkynts
    I could not figure out the reason for the error, I don't get it either when I try. I did not fully test, but did run the macro a few times without error. That said, I don't think I tried it when the sheet is completely empty...
    sorry your code now working very well without any inefficient ,its my mistake i didnt setup page brakes
    thank you very much for helping me and wish you all the best

  11. #11
    Registered User
    Join Date
    09-24-2011
    Location
    Yemen
    MS-Off Ver
    365
    Posts
    77

    Re: how to make macro button to print page that has the active cell only?

    Quote Originally Posted by stnkynts View Post
    I don't get an error with Arkadi's code, it seems to be fairly sound. Here is another way of doing the same (Arkadi's code is actually a little more encompassing but may be more than you need)

    Please Login or Register  to view this content.
    this good is working great but it doesn't work on last page (that has the last page break line) its print the upper page instead of the current page
    i wonder if u could edited
    I really appreciate everything you've done to help me

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Print current page with active cell with VBA code Excel 2010
    By ruznemat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2017, 08:42 AM
  2. Macro that will copy cells to another area & print active page (not sheet)
    By Cyali in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2012, 09:34 PM
  3. Macro to Publish Print Area from Active Sheet to Web Page
    By jdinning in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 03-11-2009, 12:41 PM
  4. Button to print non-active page - How?
    By Bafa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-20-2006, 11:53 PM
  5. Replies: 1
    Last Post: 11-24-2005, 07:29 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1