Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Joanne
 
Posts: n/a
Default If Then Statement Clarification

This is an example of what I am trying to do

Cell A1 1/1/04
A2 12/31/04
A3 1/1/07

If A2-A1 = 1460
A3-A2 = 731
Since A2-A1 is greater than A3-A2 I want to take the difference from
1460-731 (729) and add that to 1/1/04 to make a new date of 12/31/02 but if
the difference between A2-A1 and A3-A2 is negative, I want to return A3 as
the date.
Thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
Ian G
 
Posts: n/a
Default If Then Statement Clarification

Try this code

Sub Dates()
firstdates = Range("a2") - Range("a1")
seconddates = Range("a3") - Range("a2")
If seconddates firstdates Then
MsgBox Range("a3")
Else
MsgBox Range("a1") + firstdates - seconddates
End If
End Sub

Ian G

  #3   Report Post  
Posted to microsoft.public.excel.misc
Ian G
 
Posts: n/a
Default If Then Statement Clarification

If you want a formula to do the same, try
=IF((2*A2-A1-A3)<0,A3,(2*A2-A3))

Ian G

  #4   Report Post  
Posted to microsoft.public.excel.misc
Joanne
 
Posts: n/a
Default If Then Statement Clarification

Thank you Ian!

"Ian G" wrote:

If you want a formula to do the same, try
=IF((2*A2-A1-A3)<0,A3,(2*A2-A3))

Ian G


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
SET statement tutorial Daminc Excel Discussion (Misc queries) 13 January 17th 06 04:47 PM
If statement Matt Montagliano Excel Discussion (Misc queries) 1 September 8th 05 08:47 PM
Do I need a sumif or sum of a vlookup formula? PeterB Excel Worksheet Functions 0 June 1st 05 12:23 PM
What statement to use? Paul Excel Worksheet Functions 6 February 13th 05 05:23 PM
How do I fix a circular reference in a financial statement? drjayhawk25 Excel Discussion (Misc queries) 0 February 7th 05 05:19 PM


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