Solved

Excel and DateAdd

Posted on 2002-03-08
3
5,973 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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