View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Sub or Function not defined

mround is in the analysis toolpak.

You need to create a reference to analysis toolpak VBA (ATPVBAEN.xls) then
you can use it like you have shown.

however, the numbers you show produce:

0.349999999999999 (IEEE double precision limitation)

which MRound rounds to .3

maybe just add .001 to the result of multiplication by 24


TextBox10.Text = Format((CDate(TextBox9.Text) _
- CDate(TextBox8.Text)) * 24 + .001)"#.0")

--
Regards,
Tom Ogilvy




"Patrick Simonds" wrote in message
...
I am trying to get this formula to work in my macro, but it seems not to
accept the MROUND, I get a Sub or Function not defined error. I need the
MROUND so that I can get proper rounding results. The formula below is
working with times and without MROUND I sometimes get rounding errors. For
example:

15:21 - 15:00 returns .35 which should round to .4 but rounds to .3


TextBox10.Text = Format(Round(MROUND((CDate(TextBox9.Text) _
- CDate(TextBox8.Text)) * 24), 1), "#.0")