Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Soluution macro or function

I have a table below and I want to delete all material rows except the newest
date/last purchase date. Any suggestions

material purch date
A 1/2/2008
A 2/10/2007
A 2/12/2008
A 12/2/2006
A 3/23/2008
A 8/17/2007
B 1/2/2008
B 2/10/2007
B 2/12/2008
C 12/2/2006
C 3/23/2008
C 8/17/2007

--
Sue
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default Soluution macro or function

If you apply autofilter to the purchase date column, then when you use
the filter pull-down the dates will be in sequence with the latest
date at the bottom of the list. If you select this date, then only
those rows will be displayed. You can then easily highlight the
visible rows, click <copy and paste only those rows to another sheet.
You can then delete the first sheet if you really don't want all the
data.

Hope this helps.

Pete

On Feb 23, 9:42*pm, Sue wrote:
I have a table below and I want to delete all material rows except the newest
date/last purchase date. Any suggestions

material * * * *purch date
A * * * 1/2/2008
A * * * 2/10/2007
A * * * 2/12/2008
A * * * 12/2/2006
A * * * 3/23/2008
A * * * 8/17/2007
B * * * 1/2/2008
B * * * 2/10/2007
B * * * 2/12/2008
C * * * 12/2/2006
C * * * 3/23/2008
C * * * 8/17/2007

--
Sue


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Soluution macro or function

Try this to sort and delete rows.
Sub lastpurdate()
lr = Cells(Rows.Count, "a").End(xlUp).Row
'sort
Range("A2:B" & lr).Sort Key1:=Range("A2"), Order1:=xlAscending, _
Key2:=Range("B2"), Order2:=xlAscending, Orientation:=xlTopToBottom
'delete rows
For i = lr To 2 Step -1
If Cells(i - 1, "a") = Cells(i, "a") And _
Cells(i - 1, "b") < Cells(i, "b") Then Rows(i - 1).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Sue" wrote in message
...
I have a table below and I want to delete all material rows except the
newest
date/last purchase date. Any suggestions

material purch date
A 1/2/2008
A 2/10/2007
A 2/12/2008
A 12/2/2006
A 3/23/2008
A 8/17/2007
B 1/2/2008
B 2/10/2007
B 2/12/2008
C 12/2/2006
C 3/23/2008
C 8/17/2007

--
Sue


Reply
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
MACRO & FUNCTION FARAZ QURESHI Excel Discussion (Misc queries) 2 February 11th 08 06:26 PM
Is there a Function or Macro for This? Marilyn Excel Discussion (Misc queries) 6 November 6th 07 03:21 AM
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
macro or function? CMD Excel Discussion (Misc queries) 0 October 4th 06 02:00 PM
Macro within a function? stevieboy1313 Excel Worksheet Functions 1 September 19th 06 07:57 PM


All times are GMT +1. The time now is 11:46 PM.

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"