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

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.
LVL 6
Eric ZwiekhorstSAP Business ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bruintjeCommented:
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

HAGD:O)Bruintje
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eric ZwiekhorstSAP Business ConsultantAuthor Commented:
It does work but adds the pagebreak after the activecell.

I found a answer myself that works

ActiveCell.Rows.Activate
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
this does the job
0
Eric ZwiekhorstSAP Business ConsultantAuthor Commented:
ActiveCell.Rows.Activate
    ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell

this does the job, your's did add pagebreak but after the active cell??
0
bruintjeCommented:
sorry thought that was asked for

>>after I searched a cell

but clearly not ..... :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.