ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using DateAdd function with cell values. (https://www.excelbanter.com/excel-programming/371699-using-dateadd-function-cell-values.html)

loren.pottinger

Using DateAdd function with cell values.
 
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


Jim Thomlinson

Using DateAdd function with cell values.
 
Try this...

Sub GetAmOrDep()

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

If TestDate < Range("I7").Value Then
Range("K7").Copy Destination:= Range("M7")
End If
End Sub
--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

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



Bob Phillips

Using DateAdd function with cell values.
 
see public.excel

--
HTH

Bob Phillips

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

"loren.pottinger" wrote in message
oups.com...
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




loren.pottinger

Using DateAdd function with cell values.
 
Thanks Jim, but to no avail. I'm think the proplem is with my use of
the DateAdd function. I have never used it with cell values before. Do
you know if it is allowed, can't really find anything on the internet.

Jim Thomlinson wrote:
Try this...

Sub GetAmOrDep()

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

If TestDate < Range("I7").Value Then
Range("K7").Copy Destination:= Range("M7")
End If
End Sub
--
HTH...

Jim Thomlinson


"loren.pottinger" wrote:

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





All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com