Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I write If then statements?

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   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How do I write If then statements?

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
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
how do I write a formula for If And statements ex. if = to ? and MacroLearning New Users to Excel 6 December 19th 06 07:28 PM
IF Statements (Mutliple Statements) Deezel Excel Worksheet Functions 3 October 19th 06 06:13 AM
operator statements, shorting when reusing one of the statements? KR Excel Programming 1 August 4th 05 06:20 PM
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? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
Better Way to Write This? Michael[_27_] Excel Programming 2 June 24th 04 09:38 AM


All times are GMT +1. The time now is 01:55 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"