View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
William[_2_] William[_2_] is offline
external usenet poster
 
Posts: 227
Default selecting rows of data

Hi mimmo

Can you not bring all the data into Excel (either into a new workbook or new
worksheet within the current workbook).

Then perhaps you could try this to select the relevant data......

Sub test()
Dim r As Range, r1 As Range, c As Range
With ActiveSheet
Set r = .Range(.Range("A1"), Range("A" & Rows.Count).End(xlUp))
r.Replace What:="location", Replacement:="=2/0", LookAt:=xlWhole
Set r = .Columns("A:A").SpecialCells(xlCellTypeFormulas, 23)
r = "location"
Set r1 = Nothing
For Each c In r
If c.Offset(1, 0) = "depth" Then
If r1 Is Nothing Then
Set r1 = .Range(c, c.Offset(1, 0))
Else
Set r1 = Union(r1, .Range(c, c.Offset(1, 0)))
End If
End If
Next c
If Not r1 Is Nothing Then r1.EntireRow.Select
End With
End Sub
--


XL2003
Regards

William



"mimmo" wrote in
message ...

Hi: we just started using a new system where we capture location and
depth data from a sounder, for making depth maps of lakes.
Basically the data streams continuously into a text file which we can
easily import into Excel, but we have to select certain rows first.
Each row of data has an identifier in the first column that tells us if
it's depth or location data. The problem is that there is more location
data then there is depth, so here's what we need to do:

every time a row with location data is followed by a row of depth data,
then we want to keep both of those rows

every other combination that is different from above, delete the rows

so for example, if these were the rows (row number shown):

1 location
2 location
3 location
4 depth
5 location
6 location
7 depth

then the rows we want to keep are 3,4,6 and 7

sorry for the lengthy post, this is my first, I just thought it's a
unique problem and hopefully some of you will find it interesting and
provide a solution

thanks


--
mimmo
------------------------------------------------------------------------
mimmo's Profile:
http://www.excelforum.com/member.php...o&userid=26724
View this thread: http://www.excelforum.com/showthread...hreadid=399784