removing data

  • Thread starter Thread starter Lucile
  • Start date Start date
L

Lucile

Hi all,
I need your help!

I have a column of data that goes up, down, up, down... and finally
increases to a maximum. I need to remove the up and down portion to keep only
the final increase...

Any ideas how to do that?
Thanks
 
This is not a very simple problem. The issue is defining the last minimum.
It depends on your data when and how to define the lat minimum. Can you help?
 
Here we start at the bottom of a column and work upward. We check that the
data is increasing (moving downwards). When we find the breakpoint, we
delete all cells above the point.

Sub lucile()
n = Cells(Rows.Count, "A").End(xlUp).Row
v = Cells(n, "A").Value
For i = n - 1 To 1 Step -1
If v < Cells(i, "A").Value Then
Exit For
Else
v = Cells(i, "A").Value
End If
Next
Range("A1:A" & i).Delete Shift:=xlUp
End Sub
 
It was what I was thinking. Finding the last minimum is the best option. But
how do you find it!? Because it is not the minimum of the columns.

What else do you need to know?
 
Tightening up your code just a little bit...

Sub lucile()
Set R = Cells(Rows.Count, "A").End(xlUp)
For i = R.Row - 1 To 1 Step -1
If Cells(i, "A").Offset(1).Value < Cells(i, "A").Value Then Exit For
Next
Range("A1:A" & i).Delete Shift:=xlUp
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top