Horizontal Cell Borders at Page Breaks

Fergus

Well-known Member
Joined
Mar 10, 2004
Messages
1,174
I have a long worksheet with only the vertical cell borders shown such that when printed it appears as a number of columns. When I print it (with column headings repeated) I would like to generate a horizontal border across the last cells before the page break to clean up the appearance. The page breaks are not forced, just depend on the margin settings. The positions of page breaks will vary as at times there is a need to insert new rows into the worksheet at different locations. I know I can easily do this job manually in page break view by setting the borders but does anyone know how this can be automated?
 
Hi again P. Sitaram and thanks for your last help. Items 1 & 2 I have now got to work fine, so thanks a lot, but I am having big problems trying to write a code to delete any horizontal cell borders below rows 1- 7 which are repeated header rows at the top of each page and I don't want to delete any cell borders in the column headings. The width of each worksheet is from cols D to AH (cols A,B & C are hidden). The maxiumum length of any of the 12 worksheets is less than 150 rows. The latest bit of code I have come up with is:

Sub noline()

For Each c In Activbesheet.HPageBreaks

With c.Location
With Range("D7:AH150").Borders(xlEdgeBottom)
.LineStyle = xlNone
End With
End With

Next

End Sub


But this clearly isn't working and now I'm lost. :banghead: I did read up on Ranges and all sorts of other topics too and have tried to adapt and/or combine many different examples given in the help files but all without success so far. Have you any more advice? - or shall I revert to doing it manually?
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try:

Code:
For Each rw In Range("D7:AH150").Rows
    
    rw.Borders(xlEdgeBottom).LineStyle = xlNone
Next
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,219
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top