+ Reply to Thread
Results 1 to 9 of 9

Print area and borders macro based on cells contents

  1. #1
    Registered User
    Join Date
    09-16-2008
    Location
    Jersey
    Posts
    57

    Print area and borders macro based on cells contents

    Hi Guys

    I am trying to get a few things together in the same macro, i have most of it but it's messy when i put it together and doesn't quite work.
    My intention was to clear print area, have the first 2 rows printed in all sheets if more than 1, have a center foot with page No of, in landscape printed in greyscale.

    Please Login or Register  to view this content.

    Then set the print area based on the last cell with value,

    Please Login or Register  to view this content.
    then to finish add a thick border around the "print area" area with a hairline border on the inside.
    Please Login or Register  to view this content.
    Any help will be really apreciated.

    Regards
    Jsantos
    Last edited by jsantos; 10-22-2012 at 08:34 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Print area and borders macro based on cells contents

    Try this:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-16-2008
    Location
    Jersey
    Posts
    57

    Re: Print area and borders macro based on cells contents

    Hi JBeaucaire

    Thanks it looks a lot tidier, unfortunatly when i try to run it an error message comes up "Object doesn't support this property or method".
    It's not like i use excell everyday but it's the first time i see this error.

    Can you help


    Many thanks
    Jsantos

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Print area and borders macro based on cells contents

    Try this change:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-16-2008
    Location
    Jersey
    Posts
    57

    Re: Print area and borders macro based on cells contents

    Hi JBeaucaire
    Made the change as you sgested and it now runs for about 4 seconds to then give me error "400"
    At first it was giving me far more pages than i expected, but manage to find out that the sheets i was using initially had borders that would make the print area go to the 50 plus pages. I corrected this but can't see the reason for this error code come up.
    As far as i can see everything i wanted gets done.

    Many thanks for your pacience and help

    Jsantos

  6. #6
    Registered User
    Join Date
    09-16-2008
    Location
    Jersey
    Posts
    57

    Re: Print area and borders macro based on cells contents

    Hi JBeaucaire
    The reason for the error was because one of the sheets was protected.
    One last question:
    Would it be possible to stop the above macro to apply to one sheet in the workbook? In this case the sheet would always have the same name ("Header")?


    Many thanks
    Jsantos

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Print area and borders macro based on cells contents

    This is for the one sheet only:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-16-2008
    Location
    Jersey
    Posts
    57

    Re: Print area and borders macro based on cells contents

    Hi JBeaucaire

    Your change will make the macro run just for that particular sheet, what i want is to have the macro applying my instructions to all the sheets but the "Header" sheet.
    My workaround is as follows, just tought there would be something that would stop the macro running on that sheet.
    It takes quite a while to run this macro thats why i was thinking about a way to remove this sheet from it.

    Regards
    Joaquim


    Please Login or Register  to view this content.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Print area and borders macro based on cells contents

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    09-16-2008
    Location
    Jersey
    Posts
    57

    Re: Print area and borders macro based on cells contents

    Many Many thanks
    This ends my long list of requests.

    Untill the next time

    Kind regards
    Jsantos

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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