View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mishell[_3_] Mishell[_3_] is offline
external usenet poster
 
Posts: 22
Default find header then replace header with number of entries below heade

You could also do it with something like this:

Sub Nan2()
C = "A"

LastRow = Cells(Rows.Count, C).End(xlUp).Row

cpte = 0
For i = LastRow To 1 Step -1
If Cells(i, C).Value < "nan nan " Then
cpte = cpte + 1
Else
Cells(i, C).Value = cpte
Cells(i, C).Offset(0, 1) = 1
cpte = 0
End If
Next

End Sub

Mishell

"kjotro" a écrit dans le message de news:
...
I have a data set that contains over 66,000 lines. I would like to search
for
each 'nan nan' then replace it with the number of entries that follow
until
the next 'nan nan'. Ex. the first 'nan nan' to be replaced with '7',
second
with '17'. I would also like to enter a '1' in the cell to the right of
each
replaced value.
Thanks in advance. Kevin

nan nan
-89.34548 29.000135
-89.34636 28.998375
-89.346654 28.997788
-89.347534 28.997788
-89.347827 28.997495
-89.346654 28.996321
-89.341373 29.000135
nan nan
-89.424686 28.923276
-89.424686 28.924156
-89.423806 28.925036
-89.423806 28.925916
-89.422926 28.926796
-89.422926 28.927383
-89.421752 28.92885
-89.420872 28.92885
-89.419992 28.929437
-89.419112 28.929437
-89.417939 28.928263
-89.417939 28.927383
-89.418525 28.92709
-89.419112 28.92709
-89.423219 28.922983
-89.424099 28.922983
-89.424686 28.923276
nan nan
-89.393884 28.938237
-89.392417 28.939704
-89.39183 28.939411