View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
THEFALLGUY
 
Posts: n/a
Default Deleting rows in a macro in Excel

I have to delete a series of rows within several spreadsheets. I am trying
to write code for a macro that will search for wordage within a cell (Edit -
Search), and once the search engine finds that cell, I will delete all rows
directly above that cell (not including the first two rows).

The issue I am having is that the wordage that is the result of the search
is not always in the same row; i.e. sometimes it is in row 43, sometimes 44,
etc. Is there a way within a macro to declare that I want all rows deleted
above a specified row, not including the first two rows? This is the code I
have thus far:

Cells.Find(What:="EQUIPMENT", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Rows("44:44").Select
Range(Selection, Selection.End(xlUp)).Select
Rows("4:44").Select
Range("A44").Activate
Selection.Delete Shift:=xlUp

Thank you,
THEFALLGUY