If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > RoundUp / RoundDown in VBA ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-10-04, 07:12
jparagg jparagg is offline
Registered User
 
Join Date: Oct 2003
Posts: 17
Red face RoundUp / RoundDown in VBA ?

Hello,

Are there equivalent functions for RoundUp RoundDown in VBA ?
On the cell if I put RoundDown(1234, -1) it gives me 1230
but I could not find a function to achieve this while writing this in a macro.
Do I need to do any inclusion ?
It gives "Sub or Function not defined" error for RoundDown on compilation.

For the time being, I wrote a dummy function to do the RoundDown as it was very urgent.

Also the Round function behaves diffently in VBA. It does not accept a negative num_digits parameter. i.e. Round(1234, -1) fails in VBA but works as "RoundDown" in the xls.

Is there no way to achieve RoundDown in VBA ??

Regards,

Parag
Reply With Quote
  #2 (permalink)  
Old 05-10-04, 10:57
actuary actuary is offline
Registered User
 
Join Date: Mar 2004
Location: Fort Worth, Texas, USA
Posts: 68
Application.WorksheetFunction.RoundDown(1234, -1)
Reply With Quote
  #3 (permalink)  
Old 05-11-04, 02:35
Rocket71 Rocket71 is offline
Registered User
 
Join Date: Mar 2004
Location: Adelaide, Australia
Posts: 32
Smile a little clarification

What actuary is trying to say is that you can use excel functions in vba by using the WorksheetFunction property of the Application object.

In vba explorer, goto the the Object Browser (menu View - Object Browser (or F2)). Go through the classes until you find WorksheetFunction, then you will see all the members of it in the right hand pane. see attachment.

HTH.
Attached Images
File Type: jpg objbrowser.jpg (109.2 KB, 3233 views)
__________________
Regards,
Rod.

Programmer response #5 - "Even though it doesn't work, how does it feel?"
Reply With Quote
  #4 (permalink)  
Old 05-11-04, 09:34
jparagg jparagg is offline
Registered User
 
Join Date: Oct 2003
Posts: 17
Smile

Thank you for the detailed reply.
It is very interesting, I had never used WorksheetFunction in VBA.
That's great.
Thanks again.
Reply With Quote
  #5 (permalink)  
Old 07-08-08, 23:45
joykutty joykutty is offline
Registered User
 
Join Date: Jul 2008
Posts: 1
How do I use Roundup function in VBA for Access 2007
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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