LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using DateValue function

I am trying to find the number of days between two date
using the following formula: =IF(D2=(DATEVALUE
("1986/1/1")),(DATEVALUE("2004/12/15")-I2),(DATEVALUE
("2004/12/15")-D2)) in a macro. Here is the code in the
macro:
ActiveCell.FormulaR1C1 = _
"=IF(RC[-2]=(DATEVALUE(""1986/1/1"")),(DATEVALUE
(""2005/01/01"")-RC[3]),(DATEVALUE(""2005/01/01"")-RC[-
2]))"
I need to have the 2nd and 3rd dates be dynamic when I
run the script and not have them hardcoded. The 1986/1/1
date will always be the same date. I have tried the
following code:
vardate = Right(Date, 4) & "/" & Month(Date) & "/1"
DateValueUS = Application.Evaluate("DateValue(""" &
vardate & """)")
' ActiveCell.FormulaR1C1 = _
"=IF(RC[-2]=(DATEVALUE(""1986/1/1"")),(DateValue
(DATEVALUEUS)-RC[3]),(DATEVALUEUS-RC[-2]))"
but it does not work. Does anybody have a solution to
populate the column with the number of days between two
dates? Thanks.
 
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
Help with DateValue function (part 2) Pank New Users to Excel 4 March 30th 07 08:50 AM
Help with DateValue function. Pank New Users to Excel 7 March 29th 07 02:04 PM
Help With DATEVALUE Dick Frederick Excel Worksheet Functions 3 January 28th 07 09:18 PM
datevalue LarryTheK Excel Worksheet Functions 8 July 23rd 05 03:24 AM
Conditional Sum and DATEVALUE function Vlad Excel Worksheet Functions 2 June 14th 05 05:00 PM


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