+ Reply to Thread
Results 1 to 19 of 19

Clear Print Area Sub Vba Code

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Clear Print Area Sub Vba Code

    Hello,
    I have a button in the worksheet and I need a code that when I click the button then it will clear the print area.

    Or

    Is it possible to set a print area from Column A1:T31 as page 1

    and A32:T44 as a Page 2 then the rest will not be necessary to print.


    thanks. I hope the second option will work : o)

    Thank you

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Clear Print Area Sub Vba Code

    Possibly...
    Sub Print_2_Pages()
        With ActiveSheet
            .PageSetup.PrintArea = ""
            .ResetAllPageBreaks
    
            .PageSetup.PrintArea = "$A$1:$T$44"
            .HPageBreaks.Add Before:=Range("A32")
        End With
    End Sub

  3. #3
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    Good morning,
    I did add the code and I added the button for the clear print area.
    It kinda work.
    There is a dotted line in row 24 which it should go to the row 31. So the pages should make 2 pages only.

    Do I need to fix the margins? Thank you
    Attached Files Attached Files

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Clear Print Area Sub Vba Code

    Change the margins, row heights, or scaling.

  5. #5
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    Ok... thanks.

    One more thing maybe you can help me with it.
    I am trying to find something I can set the footer and the header center to set a font. I want it to added in the vba code where the margin button is.

    Can you please?

  6. #6
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    What I meant trying to set a font for the center footer to maybe 20 with arial black. I need to add the code in the vba code which I already have in there.

  7. #7
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    I tried to add this in it but seems doesn't not work.

    .CenterFooter.FontSize = 20

  8. #8
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Clear Print Area Sub Vba Code

    Try...
    ActiveSheet.PageSetup.CenterFooter = "&""Arial,Regular""&20&F"

  9. #9
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    Hi
    Sorry I forgot to mention that I need to place the button in the other sheet and it will stay there. Can you indicate the code to work for Sheet2 only. Please.... thank you.

    Sub Print_2_Pages()
        With ActiveSheet
            .PageSetup.PrintArea = ""
            .ResetAllPageBreaks
    
            .PageSetup.PrintArea = "$A$1:$T$44"
            .HPageBreaks.Add Before:=Range("A32")
        End With
    End Sub

  10. #10
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Clear Print Area Sub Vba Code

    Replace
    With ActiveSheet
    with
    With Worksheets("Sheet2")

  11. #11
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    Hi
    the center footer showed "FONTSETTING" which is the name for workbook.
    It should say "JULY 2020"

    I added the code in it. Can you please double check to see if it correct.
    Instead of arial, can you make it arial black to make it more bolded?


    Thanks :o )
    Attached Files Attached Files

  12. #12
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Clear Print Area Sub Vba Code

    Try
            .CenterFooter = "&""Arial Black,Regular""&20&D"
            .CenterHeader = "&""Arial Black,Regular""&20&D"
    and adjust your margins to fit the text.

  13. #13
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    Hi
    I saw you add the &[DATE]. I removed that.
    Does it suppose to create a footer and header because of this code?
    .CenterHeader = "TESTING 1" 'CHANGE HERE
            .CenterHeader = "&""Arial Black,Regular""&11&D"
    Let say I typed Testing 1 as a centerheader and footer center is "Testing 2"

    what ever I typed something on that code, it suppose to appear in the sheet, right?
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    When it prints it shows the date and not the testimg 1 or testimg 2 as a header and footer

    Thanks

  15. #15
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    Hi Deangelor,

    Nevermind, I was able to figured it out.

    Thank you for all you help.

  16. #16
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Clear Print Area Sub Vba Code

    OK and good luck!

  17. #17
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    Hello

    I have more favor to ask, if you can add a color red on the font on the JULY 2020 on the code below. Please.... thank you.


    .CenterHeader = "&""Georgia Pro Black,Regular""&10& JULY 2020"

  18. #18
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    Should I replaced “regular” to “Ref”? Or is there ant code to add in it.

    Thanks

  19. #19
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,813

    Re: Clear Print Area Sub Vba Code

    I meant “Red”

+ 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. Duplicate Value in a clear print area
    By RJ1969 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2019, 12:57 AM
  2. [SOLVED] Clear Print area macro seems to hang
    By sipa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2016, 11:59 AM
  3. Replies: 1
    Last Post: 01-12-2012, 05:49 AM
  4. [SOLVED] When I clear a print area, it still prints.
    By AngelaArdettoMicrosoftOfficeExcelWorkshe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-23-2006, 03:35 PM
  5. Print Area:Hope I am able to clear what I want.
    By Mandeep Dhami in forum Excel General
    Replies: 3
    Last Post: 11-16-2005, 10:55 AM
  6. Print Area:What would be the code for setting the print area
    By wammer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2005, 02:05 AM
  7. Can't Clear Print Area
    By GeorgeF in forum Excel General
    Replies: 2
    Last Post: 08-05-2005, 02:05 PM

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