Help with VBA (or VB) DateAdd, WORDAY functions, date format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A custom dialog box (input form) I created for Excel has 2 date fields--one
90 days later than the other. The first field defaults to today:

datInitDate.Value = Date$
(displays as 01-06-2005)

The second defaults to 90 days later than whatever winds up in that field:

datComplDate.Value = DateAdd("d", 90, datInitDate.Value)
(displays as 4/6/2005)


How do I make these two dates have the same format?

Alternatively, I also added the Analysis Toolpack, put a reference to it in
my VBA project and tried using these--which fail as "out of range" (both are
empty):

TODAY() and (or TODAY, with no parentheses)
WORKDAY(TODAY(),90)

This fails and I cannot find any help (online or in my Object Browser for
all libraries) to see a working example.

Do TODAY/WORKDAY require DIM statements? (Are these arrays?)
 
datInitDate.Value = Format(Date,"mm-dd-yyyy")

datComplDate.Value = Format(Date + 90,"mm-dd-yyyy")

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks Bob! That works great! The VBA Help for FormatDate, and Format were
not so easy to decipher as your cogent examples!
 
Pleasure Jenelle. Thanks for the feedback.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
User error discovered:

The Format(....+90) worked on my machine (because I have VB); however, the
compiled project fails on users machines who have Office 2002 (but not VB)
installed.

Ouch.
 
Doesn't need VB. What error is it?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
compile error: can't find project or library.

I thought it may have been the analysis toolpack, so I had one use load that.

where it breaks when I click debug is at the date equations I've shown. (I'm
using Officd 2003 Std Ed, other users (3 of them) have Office 2002 (don't
know any more detail than that).
 
Go to the VB E and check Tools>References on the machine with the problem.
See if there are any Missing references, if so correct them.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Back
Top