Yes, Dave, that's my intent, to delete the last value only and only if it is
LESS than 90% of the penultimate value, including "0", which crashes the
calcs.
z.entropic
"Dave Thomas" wrote:
He wants to delete the last value only if it's less than 90% of the
penultimate value. Your macro is deleting the last value if it's greater
than 90% of the penultimate value. The code should be: If ActiveCell.Value <
(ActiveCell.Offset(-1, 0).Value * 0.9) Then ActiveCell.Value = ""
"Mike H" wrote in message
...
try
Sub marine()
Dim LastColumn As Long
With ActiveSheet
LastColumn = .Range("A1").SpecialCells(xlCellTypeLastCell).Colu mn
End With
For x = 1 To LastColumn
Columns(x).Select
ActiveCell.Offset(65535, 0).End(xlUp).Select
If ActiveCell.Value (ActiveCell.Offset(-1, 0).Value * 0.9) Then _
ActiveCell.Value = ""
Next
End Sub
Right ckick sheet tab view code and paste in
Mike
"Don Guillett" wrote:
Be careful about running this twice.
Sub deletelastiflessthan90()
For i = 1 To 36' chg to suit
lr = Cells(Rows.Count, i).End(xlUp).Row
If Cells(lr - 1, i) < 0.9 * Cells(lr, i) Then Cells(lr, i).Clear
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"z.entropic" wrote in message
...
My worksheets have dozens of columns, each with up to a few thousand
rows.
Both enumber of columns and rows varies from one data set tp another.
I'd like to have a macro that would delete the last value in each
column,
but only if it's less than 90% of the penultimate value in that column.
Obviously, simply recording a macro with a Ctrl-Down key sequence in
each
column will not work as the the last value is recorded as a static
address,
but maybe using the OFFSET function would...
Help, please...
z.entropic