Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Sub or Function not defined

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")


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Sub or Function not defined

Hi Patrick,

When doing calculations in sheets, differecen is shown as 0.35. But when
forcing 15 numbers after comma, it becomes 0.3499999... which is rounded
at 0.3

One (absolutely not nice) method is to first round at 2 numbers after
comma (0.35) and then round at 1 after (0.4)

HTH
@+
FxM



Patrick Simonds a écrit :

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")


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sub or Function not defined

Patrick,

In Excel, go to the Tools menu, choose Add-Ins, and put a check
next to "Analysis Tool Pak - VBA". Then, in VBA, go to the Tools
menu, choose References, and put a check next to ATPVBAEN.xla.
You can then use the functions in the Analysis Tool Pak in your
VBA code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"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")




  #4   Report Post  
Posted to microsoft.public.excel.programming
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")




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
using a defined Name in a function cole Excel Worksheet Functions 2 July 31st 09 04:36 PM
Sub or function not defined wmdmurphy Excel Worksheet Functions 13 May 24th 09 05:50 PM
sumproduct function / VB user defined function aw Excel Discussion (Misc queries) 3 September 23rd 08 09:05 AM
Max of a defined function Barb Reinhardt Excel Worksheet Functions 4 May 18th 06 05:58 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"