Solved

Excel and DateAdd

Posted on 2002-03-08
3
5,975 Views
Last Modified: 2009-07-29
In excel I would like to use the DateAdd function to add a number of days to a date which are contained in cells using the following function

Function DatesAdd(iinterval As String, nnumber As Integer, ddate As Date) As Integer

    DatesAdd = DateAdd(iinterval, nnumber, ddate)

End Function


In the formula bar - how would I call this function ?

I have tried

=DatesAdd("d",D11,B11)

but get the #Value! error

DarrinE

0
Comment
Question by:DarrinE
3 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6850116
Are you sure that DateAdd is existing as a formula in Excel. I don't see it!

You can do simply : =D11+B11
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6850122
You are returning a date so you should declare the function in your module as:

Function DatesAdd(iinterval As String, nnumber As Integer, ddate As Date) As Date

   DatesAdd = DateAdd(iinterval, nnumber, ddate)

End Function

0
 
LVL 2

Author Comment

by:DarrinE
ID: 6850130
Good pickup TimCottee - my silly error not picking it up that I was not returning a date - dont you hate days like that - I spent nearly an hour checking and double checking what I was doing ... I think I need some sleep .. lol

DarrinE
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question