How to pagebreak

B

Bilal A F

Hello everyone,

My problem is that I need to automate insertion of pagebreak in an excel
document.

I pull data from database and spit it out on an excel sheet and then I want
to write a short VB application or just a macro which insert page breaks at
a particular places which i will mark on excel sheet while spitting out
data.

so this macro/routine should just look through an entire coulmn in excel
sheet and when it found the mark it will just insert the page break
automatically and replace the mark by null.

I dont have enough experience in writing VBA routines. I would be very
thankful if someone can guide me.

Thanks a lot,

Bilal
 
T

Tom Ogilvy

Turn on the macro recorder and insert a pagebreak. Turn it off.

That will give you the syntax for inserting a pagebreak. You can loop
through your cells looking for your mark

Dim cell as Range
for each cell in Range(Range("A1"),Cells(rows.count,1).End(xlup))
if cell.Value = "Mark" then
' code to insert pagebreak
end if
Next
 

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

Similar Threads

VBA pagebreak question! 1
Pagebreak property 1
Insert row after pagebreak 2
Pagebreak function problem 2
PageBreak-broke? 13
Vba Excel Page Breaks 0
Automate Page Break 2
PageBreak Problems 1

Top