+ Reply to Thread
Results 1 to 13 of 13

Bottom border on Excel pages (Add and Remove)

  1. #1
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Bottom border on Excel pages (Add and Remove)

    I have this code which adds a border to every page break. This will be the bottom border for a multi-page Excel sheet.
    When I edit the document though by adding or subtracting rows, the border will not coincide with the page breaks.
    I want to have something which first removes all the borders which span columns A-I (9 columns). There will be other regions with borders but these will not fully span columns A-I, so leave these as they are.

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Bottom border on Excel pages (Add and Remove)

    Alternatively, can the following events be called up at once.
    1. Add borders before printing: Sub page_break_border()
    2. Print.
    3. Remove border after printing: Sub page_break_border_undo()

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Bottom border on Excel pages (Add and Remove)

    Have you considered using footers or the "repeat this row every page" feature to put a border at the bottom of each printed page?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Bottom border on Excel pages (Add and Remove)

    @mikerickson
    I have considered a footer. Using an image was the best choice ... until I found out that footers have a limited width. Using underscores was not really an option for me.
    With "repeat rows at every page", I have used this for the top of pages where I need a couple of rows on every page.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Bottom border on Excel pages (Add and Remove)

    My bad. The repeat rows feature only works at the top.

  6. #6
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Bottom border on Excel pages (Add and Remove)

    This seems to work.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Bottom border on Excel pages (Add and Remove)

    A funny thing seems to happen, with Sub page_break_border_undo().
    Depending on the zoom %, it may or may not remove the border on the page break.
    If I zoom out to 10%, it removes all border on page breaks. If I zoom in to 100%, it removes border on first page break only.
    Why does this happen?

    Note: This applies in Normal View. When in Page Break Preview, the problem goes away.
    Last edited by Un-Do Re-Do; 08-08-2017 at 12:58 AM.

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Bottom border on Excel pages (Add and Remove)

    thats strange
    are you referring to Zoom or scaling?
    because Zoom doesnt change the page breaks

    Please Login or Register  to view this content.
    ^what happens here?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  9. #9
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Bottom border on Excel pages (Add and Remove)

    @humdingaling
    I am referring to Zoom level.
    I don't expect it to occur either. Later on I found that problem goes away when in Page Break Preview.
    The sub in post #8 brings up the print dialog. So first add border, then print, then remove border. Remove is required because document is edited and printed frequently.

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Bottom border on Excel pages (Add and Remove)

    sorry let me rephrase
    what do you do when the print dialog comes up
    if you just click print....so you need the dialog at all?

    if you play with any settings that may be something that inadvertently changes the pagebreaks which is why it doesnt remove the borders

    to be sure ..if your testing you can add a debug line to capture the ranges

    Please Login or Register  to view this content.
    Put this in the loop in both the borders and undo macro to see if you get exact same ranges twice

  11. #11
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Bottom border on Excel pages (Add and Remove)

    @humdingaling
    You're right I think, it may have something to do with the print macro.
    I didn't know how to test with "Debug.print pagebottom.location.address".
    I changed from "Application.Dialogs(xlDialogPrint).Show" to "ActiveSheet.PrintOut" and this seems to work.

    Edit - no it doesn't work again.

    Edit 2 - tried this patch, hopefully it works.
    "ActiveWindow.View = xlPageBreakPreview" at beginning of "Sub page_break_border()"
    "ActiveWindow.View = xlNormalView" at end of "Sub page_break_border_undo()"
    Last edited by Un-Do Re-Do; 08-08-2017 at 09:21 AM.

  12. #12
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Bottom border on Excel pages (Add and Remove)

    Please Login or Register  to view this content.
    using an array to capture your actual rows your page breaks occur
    ^this method will ensure what you insert as borders is exactly what you take away

    i added the activewindow.view code in because it didnt assign pb properly without it

  13. #13
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Bottom border on Excel pages (Add and Remove)

    Thank you very much, works perfectly.

+ 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. Adding only a bottom border line to a excel chart
    By Alexander_Golinsky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2015, 08:20 AM
  2. Draw bottom border on every rows from top to bottom
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2013, 09:52 AM
  3. Excel chart missing bottom border in Word
    By Beeblebrox in forum Word Formatting & General
    Replies: 15
    Last Post: 09-07-2011, 12:10 PM
  4. Missing bottom border of Excel chart in Word 2007
    By karynNL in forum Excel General
    Replies: 1
    Last Post: 09-22-2010, 02:08 AM
  5. Shared Top and Bottom Border - Bottom not printing
    By bick421 in forum Excel General
    Replies: 0
    Last Post: 01-07-2009, 03:47 PM
  6. why doesn't Excel 2003 bottom double border icon work
    By RunwithGod in forum Excel General
    Replies: 2
    Last Post: 05-17-2006, 08:30 AM
  7. Replies: 1
    Last Post: 08-11-2005, 09:05 PM

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