View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Craig Craig is offline
external usenet poster
 
Posts: 208
Default How to insert a page break in Excel VBA

This info you sent me Dave, could just get me over the "hump" Thanks!!!

"Dave Peterson" wrote:

If your activecell is in row 1, you're going to have trouble.

Where is that activecell?

if activecell.row = 1 then
'do nothing
else
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
end if

And the next question is: Are you sure you want to be depending on the
activecell?

Craig wrote:

Hi,

I want to insert a page break after a condition has been met. I created a
recorded macro to see what the code looks like then I inserted it into my
real code but got an error

Here is a snippet of the real code:
=================================
If recordCounter = 8 Then

ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
'Sheets("output").Cells(rowNum, colNum).Value="TEXT TEST"
recordCounter = 0
End If
===========================================

I know the rest of the code except for the HPageBreak statement is good
since I tested it before pasting the statement in...I tested it using the
"TEXT TEST" and it did insert sample text..but instead of inserting sample
text at Cell location (rownum, colNum) I want to insert a page break...

Any suggestions...thanks much for any help with this!!!

Craig


--

Dave Peterson