Solved

Excel and DateAdd

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 56
VB6 - Compare and highlight cell not the same 3 42
How to make an ADE file by code? 11 79
Added a column screws up code 5 50
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now