View Single Post
  #2   Report Post  
Shatin
 
Posts: n/a
Default

So you first find the string. Once the string is found, you press CTRL-SHIFT
and the UP ARROW keys. This will select all the cells in the column up to
the cell where the search string is in. Once you've done that, you choose
EditDeleteEntire row.

Or if what you mean is you have to repeat this process with many files, then
you use following VBA code:

Sub deleteRows()
Dim dString As String
Dim rng As Range
dString = InputBox("Please enter the search string.")
Set rng = ActiveSheet.UsedRange.Find(dString)
If Not rng Is Nothing Then
Range(rng, rng.End(xlUp)).EntireRow.Delete
Else
MsgBox ("Make sure you enter the correct string!")
End If
End Sub

"Farooq Sheri" wrote in message
...
I have text file which I import into Excel. There is a particular string
which I need to find (this can be in any row) so the row position is
variable. I can find this string no problem. What I want to do is once I

find
the string, then starting from the row where the string is located, I want

to
delete all rows above including the row in which the desired string is
located.

e.g the string is at Row 27, delete rows 1-27.

Thanks