Link to home
Start Free TrialLog in
Avatar of sanlorenzo
sanlorenzo

asked on

How to Insert the Cell Border only the actual printing page

I have an excel sheet  named " Sheet 1"  an have  data in  Column A to N . The data are Placed from  Row  10  to any row depends on the quantity of data .
I like to know the VBA code  to insert the border only to the page that are actually filled with data . so it mean that for instance i have only one row of data , so i will have only 1 page , that entire  page ( column A to N ) should have the Border on each cell ( from  A10 : N10  to down the end of same page ) if instead i have more data that will fill more than 1 page , i will have the border down to the last entire  page containing data . Thanks
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

You can check the pagebreak property.
Option Explicit

Sub FindPageBreak()
    Dim r As Integer
    Dim iCount
    r = 1
    Do While Rows(r).PageBreak = xlPageBreakNone
        If Rows(r).PageBreak <> xlPageBreakNone Then
            iCount = iCount + 1
            If iCount = 1 Then
                MsgBox "Row " & r & " is the start of this page"
            End If
        End If
        r = r + 1
    Loop
    MsgBox "Row " & r & " is at the top of a new page"
End Sub

Open in new window

Avatar of sanlorenzo
sanlorenzo

ASKER

Hi sir , i see you placed the code to pop up a message , however i do not need a message , i need the border in the cell of the page ( pages ) that contains  data . Thanks
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial