Force CSV page Break

M

MauditOstie

Hi y'all!
I have a big time problem!
I am creating a report using an Ascii output program.
I'm creating a CSV file to be able to open it in Excel.
I need to be able to do a Page-break through my ascii file.
Anyone knows how to do it?
Here is an example of my output report:

Date: 01/01/2003,Page: 1,
Name,Account,amount,difference
PAGE-BREAK
Date: 01/01/2003,Page: 2,
Name,Account,amount,difference
PAGE-BREAK
Date: 01/01/2003,Page: 3,
Name,Account,amount,difference
PAGE-BREAK

All i need to have is how/what character to put in the report to force
a page-break.
Thanks

MauditOstie
 
B

Bernie Deitrick

MauditOstie,

You'll need to run a macro to do it after you've imported the data
into Excel:

Sub PutInPageBreaks()
Dim myCell As Range

For Each myCell In Intersect(Range("A:A"), _
ActiveSheet.UsedRange)
If myCell.Value = "PAGE-BREAK" Then
myCell.Select
myCell.EntireRow.Delete
ActiveWindow.SelectedSheets. _
HPageBreaks.Add Before:=ActiveCell
End If
Next myCell
End Sub


HTH,
Bernie
MS Excel MVP
 
J

J.E. McGimpsey

There's no way to do that AFAIK.

However, you can use this macro to convert lines with PAGE-BREAK to
actual pagebreaks:

Public Sub ConvertPageBreaks()
Const sPB As String = "PAGE-BREAK"
Dim rFound As Range
Dim nRow As Integer
Application.ScreenUpdating = False
Set rFound = Columns(1).Find( _
What:=sPB, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=True)
Do While Not rFound Is Nothing
nRow = rFound.Row
rFound.EntireRow.Delete
ActiveSheet.HPageBreaks.Add before:=Cells(nRow, 1)
Set rFound = Columns(1).FindNext
Loop
Application.ScreenUpdating = True
End Sub

If you're not familiar with macros, you can get some help at David
McRitchie's Getting Started web page:

http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top