Solved

How to Insert the Cell Border only the actual printing page

Posted on 2014-07-27
3
157 Views
Last Modified: 2014-07-31
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
0
Comment
Question by:sanlorenzo
  • 2
3 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40222466
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

0
 

Author Comment

by:sanlorenzo
ID: 40222668
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
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 40222918
I have demonstrated the method for you to fit in with your existing code.

If you are able to use and comprehend VBA code, as your question suggests, then you should be able to incorporate this extra code into your existing code.

If not, then, you should be aware  that this is a how-to site, as opposed to a do-it-for-you site. I interpret that as meaning that if you claim to to use VBA, then your need is to know how the job is done in VBA.

If you are already using VBA, and don't understand your existing code, then I urge you to study, step-by-step, the purpose and outcome of each step.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question