View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_2_] Alan Beban[_2_] is offline
external usenet poster
 
Posts: 783
Default selecting rows of data

Alan Beban wrote:
Tom Ogilvy wrote:

Your right, thanks for the heads up.

here is the correction

=if(OR(And(A1="location",A2="depth"),A1="Depth")," Keep",#N/A)

This assumes you will never have two sequential rows with depth.

And that A1 does not contain "depth"

Alan Beban


The formula I previously posted also assumes that A1 does not contain
"depth". Try instead

Sub testIt3a()
Set rng = Range("a1:a17")
For i = rng.Rows.Count To 1 Step -1
If i = 1 And rng(i) = "depth" Then rng(i).EntireRow.Delete: Exit For
If Not rng(i) = "depth" Then
rng(i).EntireRow.Delete
ElseIf Not rng(i - 1) = "location" Then
rng(i).EntireRow.Delete
Else
i = i - 1
End If
Next
End Sub

Alan Beban