Thread: Date Formula
View Single Post
  #3   Report Post  
JulieD
 
Posts: n/a
Default

Hi Jo

If A2 & A3 each have a "N" in it then I want cell A5 to show today's date
plus 20 weeks. However, if only 1 of the cells A2 or A3 has a "N" in I
still
want A5 to show today's date plus 20 weeks.


formula in A5
=IF(OR(A2="N",A3="N"),TODAY()+140,0)
(you might need to format A5 as a date)

If both A2 & A3 have "Y" in them then I want A5 to
freeze with the date last show when 1 of the two cells had a "N" it it.


this is harder to do, as the only way i see that you could do it is to keep
a record somewhere of the value stored in A5 so if both changed to a Y you
could use a worksheet_change event to change the formula to a value - this
will have to be done through code.
e.g.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Application.ScreenUpdating = False
If Target.Address = "$A$2" Or Target.Address = "$A$3" Then
If Application.WorksheetFunction.CountIf(Range("A2:A3 "), "Y") = 2
Then
Range("AA5").Copy Range("A5")
Else
Range("A5").Copy
Range("AA5").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Target.Offset(1, 0).Select
End If
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
------
to use this code, right mouse click on the sheet tab of the sheet containing
A2 & A3 and choose view copy, copy & paste the above code into the right
hand side of the screen ...
switch back to your workbook and try it out

note, i'm storing the value of A5 in AA5 ... you might need to change this
cell reference if you have something else in AA5
note, the formula won't be re-instated into cell A5 if you change one or
both to a N if they have both been Y's

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"Jo from TX" <Jo from wrote in message
...
I am trying to write a formula that works off what is in two separate
cells.
It has several parts and maybe not all of them can be done. It would be
great if someone could help me out. Here goes.
If A2 & A3 each have a "N" in it then I want cell A5 to show today's date
plus 20 weeks. However, if only 1 of the cells A2 or A3 has a "N" in I
still
want A5 to show today's date plus 20 weeks.

Can this also be done? If both A2 & A3 have "Y" in them then I want A5 to
freeze with the date last show when 1 of the two cells had a "N" it it.