View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default How do I write If then statements?

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