Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have imported data from APO into excel. There are at least 40 rows. How
do I write an If statement. If A1 = A2 through A40 and B1=b2 through b40 and c1=c2 through c40 then keep row that has the earliest requested date. For Example Product PO# Requested Date Delivery Date A123 234 Jan 20, 2006 June 1, 2006 A123 234 Mar 2, 2006 June 1, 2006 A123 234 April 2,2006 Jume 1, 2006 I am thinking a macro can delete the later requeted adtes if the rows are =? Thanks, Terry |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Terry,
Try : '============= Public Sub Tester4() Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim i As Long Dim LRow As Long Set WB = Workbooks("Your Workbook.xls") '<<==== CHANGE Set SH = WB.Sheets("Sheet3") '<<==== CHANGE LRow = SH.Cells(Rows.Count, "A").End(xlUp).Row For i = LRow To 3 Step -1 Set rng = SH.Cells(i, "A") If rng.Value = rng(0).Value _ And rng(1, 2).Value = rng(0, 2).Value Then If rng(1, 3).Value rng(0, 3).Value Then rng.EntireRow.Delete Else rng(0).EntireRow.Delete End If End If Next i End Sub '<<============= --- Regards, Norman "If...Then Statement" <If...Then wrote in message ... I have imported data from APO into excel. There are at least 40 rows. How do I write an If statement. If A1 = A2 through A40 and B1=b2 through b40 and c1=c2 through c40 then keep row that has the earliest requested date. For Example Product PO# Requested Date Delivery Date A123 234 Jan 20, 2006 June 1, 2006 A123 234 Mar 2, 2006 June 1, 2006 A123 234 April 2,2006 Jume 1, 2006 I am thinking a macro can delete the later requeted adtes if the rows are =? Thanks, Terry |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Terry,
I should add that the suggested code assumes that the entries in the Requested Date Column are recognised as dates by Excel. --- Regards, Norman |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I write a formula for If And statements ex. if = to ? and | New Users to Excel | |||
IF Statements (Mutliple Statements) | Excel Worksheet Functions | |||
operator statements, shorting when reusing one of the statements? | Excel Programming | |||
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? | Excel Worksheet Functions | |||
Better Way to Write This? | Excel Programming |