Simple macro help

  • Thread starter Thread starter lars
  • Start date Start date
L

lars

Hello,

I have a simple macro problem, which is driving me crazy. I built a
marco to open a daily text file in excel. Once the report is open I do
a Find text, once it finds the text I want it to delete 7 rows up and
then 2 rows down. The only problem I have is that I do not want the
formula to use cell reference like the one below has. Reason is that
the rows I want deleted change for one day to the other. Below is a
example from my macro.

Cells.FindNext(After:=ActiveCell).Activate
Rows("164:170").Select
Range("A170").Activate
Selection.Delete Shift:=xlUp
Rows("164:165").Select
Selection.Delete Shift:=xlUp
Columns("A:A").Select

Thank you very much, any help will be great.

Lars
 
Something like

Set foundCell = Cells.FindNext(After:=ActiveCell)
If Not foundCell Is Nothing Then
foundCell.Offset(-7,0).Resize(9,1).Entirerow.Delete
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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


Back
Top