Solved

Excel and DateAdd

Posted on 2002-03-08
3
5,978 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…

690 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