Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default INT to ROUNDUP

Hello all, I would like some assistance.
Using Excel 2007 on Vista
Confused with RoudUp and Round in procedure
Some thing to do with remainder didgets. How do I name them as long or
whatever

Public Sub CashFlow()
Const dCashCommission As Double = 0.05
Const dCashTake As Double = 0.2
Const dCashInvest As Double = 0.6
Dim dDistribute(1 To 4) As double
Dim i As Long
dAmount = ActiveCell.Value
'This next line in the macro I would like to change to:-
dDistribute(1) = RoundUp(dAmount * dCashCommission,2)

'change from Int to RoundUp? Works with Int, can't get it to work with
RoundUp

dDistribute(1) = Int(dAmount * dCashCommission)
dDistribute(2) = Int(dAmount * dCashTake)
dDistribute(3) = Int(dAmount * dCashInvest)
dDistribute(4) = dAmount - dDistribute(1) - dDistribute(2) -
dDistribute(3)
With Range("T1:T4")
For i = 1 To 4
.cells(i).Value = .cells(i).Value + dDistribute(i)
Next i
End With
ActiveCell.Offset(1, -14).Range("A1").Select
End Sub

Any help welcome and thanks.
Skinman

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default INT to ROUNDUP

On Mon, 25 Aug 2008 15:08:28 +1000, "Skinman" wrote:

Hello all, I would like some assistance.
Using Excel 2007 on Vista
Confused with RoudUp and Round in procedure
Some thing to do with remainder didgets. How do I name them as long or
whatever

Public Sub CashFlow()
Const dCashCommission As Double = 0.05
Const dCashTake As Double = 0.2
Const dCashInvest As Double = 0.6
Dim dDistribute(1 To 4) As double
Dim i As Long
dAmount = ActiveCell.Value
'This next line in the macro I would like to change to:-
dDistribute(1) = RoundUp(dAmount * dCashCommission,2)

'change from Int to RoundUp? Works with Int, can't get it to work with
RoundUp

dDistribute(1) = Int(dAmount * dCashCommission)
dDistribute(2) = Int(dAmount * dCashTake)
dDistribute(3) = Int(dAmount * dCashInvest)
dDistribute(4) = dAmount - dDistribute(1) - dDistribute(2) -
dDistribute(3)
With Range("T1:T4")
For i = 1 To 4
.cells(i).Value = .cells(i).Value + dDistribute(i)
Next i
End With
ActiveCell.Offset(1, -14).Range("A1").Select
End Sub

Any help welcome and thanks.
Skinman


For Int( , you can substitute:

Application.WorksheetFunction.RoundUp(

--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default INT to ROUNDUP


For Int( , you can substitute:

Application.WorksheetFunction.RoundUp(

--ron


Thanks Ron, Goes without saying that it works.
If Round, and Int work as first posted why not RoundUp?
They are all worksheet functions, are some worksheet functions not directly
available to
VBA without first calling . -- Application.WorksheetFunction?

Skinman

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default INT to ROUNDUP

VBA was not written exclusively for Excel... all (at least I think all)
Office applications use it as well as several non-Microsoft products (for
example, AutoCAD and CorelDraw have it too). As a general programming
language, it has a basic set of functions built in... Int and Round are two
of them whereas RoundUp never was included in the language. To make VBA work
with the various applications it is built into, those applications have
extended libraries of functions that are specific to the individual
application itself. The mechanism Microsoft used to get at the worksheet
functions from within Excel, whether they have VBA equivalents or not, is
the WorksheetFunction property of the Application object.

Rick


"Skinman" wrote in message
...

For Int( , you can substitute:

Application.WorksheetFunction.RoundUp(

--ron


Thanks Ron, Goes without saying that it works.
If Round, and Int work as first posted why not RoundUp?
They are all worksheet functions, are some worksheet functions not
directly available to
VBA without first calling . -- Application.WorksheetFunction?

Skinman


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default INT to ROUNDUP

On Mon, 25 Aug 2008 10:03:24 -0400, "Rick Rothstein \(MVP - VB\)"
wrote:

VBA was not written exclusively for Excel... all (at least I think all)
Office applications use it as well as several non-Microsoft products (for
example, AutoCAD and CorelDraw have it too). As a general programming
language, it has a basic set of functions built in... Int and Round are two
of them whereas RoundUp never was included in the language. To make VBA work
with the various applications it is built into, those applications have
extended libraries of functions that are specific to the individual
application itself. The mechanism Microsoft used to get at the worksheet
functions from within Excel, whether they have VBA equivalents or not, is
the WorksheetFunction property of the Application object.

Rick



Also note that the VBA Round function and the Excel Round worksheet function
are NOT the same. The former uses "bankers rounding" (although I don't know of
any bankers that actually used if :-))
--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default INT to ROUNDUP

On Mon, 25 Aug 2008 22:05:45 +1000, "Skinman" wrote:


For Int( , you can substitute:

Application.WorksheetFunction.RoundUp(

--ron


Thanks Ron, Goes without saying that it works.
If Round, and Int work as first posted why not RoundUp?
They are all worksheet functions, are some worksheet functions not directly
available to
VBA without first calling . -- Application.WorksheetFunction?

Skinman


Although they may have the same name, they may not necessarily be
worksheetfunctions.

The VBA Round function and the Excel ROUND worksheet function are NOT the same.
They round differently.

For example, with zero (0) as the second argument, the Excel Round worksheet
function rounds to the nearest integer; whereas the VBA Round function rounds
to the nearest even integer.

e.g.:

N=6.5

VBA Round -- 6
Excel Round -- 7

On the other hand, the VBA INT function is the same as the Excel worksheet
function INT, so it is not even a part of the worksheetfunction group! When
you call INT, you are calling a VBA function that happens to behave the same as
the Excel worksheet function with the same name.

--ron
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
can't roundup sum swell estimator Excel Worksheet Functions 3 September 4th 08 03:48 AM
RoundUP juanpablo Excel Discussion (Misc queries) 11 July 9th 08 11:11 PM
Roundup in VBA Jeff Excel Discussion (Misc queries) 3 June 3rd 08 08:59 PM
how to use roundup r4319hb Excel Discussion (Misc queries) 2 December 24th 05 01:27 PM
Trying To Roundup only if more than zero G33kman Excel Discussion (Misc queries) 2 November 29th 05 08:26 PM


All times are GMT +1. The time now is 01:21 PM.

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"