Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Using DateAdd Function with cell values

see response in 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default Using DateAdd Function with cell values

Thanks Bob. F7 does contain a number. Could it be because I am using
cell values?

Bob Phillips wrote:
see response in 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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 459
Default Using DateAdd Function with cell values

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



Hi Loren,

from msdn
(http://msdn.microsoft.com/library/de...a814a88d.asp):

[cit]

DateAdd(interval, number, date)

Arguments

interval
Required. String expression that is the interval you want to add. See
Settings section for values.

number
Required. Numeric expression that is the number of interval you want to
add. The numeric expression can either be positive, for dates in the future,
or negative, for dates in the past.

date

Required. Variant or literal representing the date to which interval is
added.



Settings

The interval argument can have the following values:

Setting Description
yyyy
Year

q
Quarter

m
Month

y
Day of year

d
Day

w
Weekday

ww
Week of year

h
Hour

n
Minute

s
Second



[end cit]

This means that you cannot have dates in F7 and H7, but you need a number
(of month in your case, cause you used interval = "m") in F7 and a date in
H7.

--
Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy


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
Using Match function with duplicate values in an array Richard Excel Worksheet Functions 3 April 22nd 23 07:45 PM
numerical integration integreat Excel Discussion (Misc queries) 4 May 12th 06 02:40 AM
Using IF function for inbetween cell values Ivano Excel Worksheet Functions 5 March 31st 06 03:35 PM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"