LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default macro to delete the last value in each column


Why are you SELECTING? How do you know row 1 is the longest column?

lc = Cells.Find(what:="*", _
after:=Cells(1, 1), searchorder:=xlByColumns, _
searchdirection:=xlPrevious).Column


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"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






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete a Column when in a Macro-Worksheet Event? jeannie v Excel Worksheet Functions 2 July 19th 07 01:58 AM
delete a macro that isn't in macro list Jane Makinson Excel Discussion (Misc queries) 3 March 13th 06 01:10 PM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
set up a macro to delete characters in each cell of a column Rick Excel Discussion (Misc queries) 2 September 18th 05 03:02 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM


All times are GMT +1. The time now is 08:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"