Using DateAdd function with cell values

L

loren.pottinger

Both F7 and H7 contain a date yet this sub does not execute the
statements after Then.................Please help.

Sub GetAmOrDep()

Dim TestDate As Date
TestDate = DateAdd("m", Range("F7").Value, Range("H7").Value)

If TestDate < Range("I7").Value Then
Range("K7").Select
Selection.Copy
Range("M7").Select
ActiveSheet.Paste
End If
End Sub
 
B

Bob Phillips

Read help on DateAdd. It is not two dates, but an interval and a date.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
L

loren.pottinger

Thanks Bob. F7 does contain a number. My bad. If that is the case then
it should be working right?
 
B

Bob Phillips

With a valid date in H7, a valid interval in F7, and assuming that Testdate
resolves to < I7, it gets there for me.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
L

loren.pottinger

Man, I was going nuts. Thanks Bob. It does work it didn't know anything
because it made my condition false. Thanks so much again.
 
Top