Excel:after search insert pagebreak before active cell in visual basic

Posted on 2003-02-21
Medium Priority
Last Modified: 2008-01-09
I would like to add a page break after I searched a cell with the search function.
I need to select the entire row to insert pagebreak but don't know how to do this when the only reference I have is the activecell.
Question by:Eric Zwiekhorst
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 44

Accepted Solution

bruintje earned 600 total points
ID: 7992778
Hello Zwiekhorst,

you could try something like

Sub InsertBreak()
  'Will insert a page break after the activecell
  ActiveSheet.HPageBreaks.Add Before:=ActiveCell.Offset(1, 0)
End Sub


Author Comment

by:Eric Zwiekhorst
ID: 7992847
It does work but adds the pagebreak after the activecell.

I found a answer myself that works

ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
this does the job

Author Comment

by:Eric Zwiekhorst
ID: 7992860
    ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell

this does the job, your's did add pagebreak but after the active cell??
LVL 44

Expert Comment

ID: 7993786
sorry thought that was asked for

>>after I searched a cell

but clearly not ..... :)

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This article was originally published on Monitis Blog, you can check it here . If you have responsibility for software in production, I bet you’d like to know more about it. I don’t mean that you’d like an extra peek into the bowels of the sourc…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

764 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