![]() |
RoundUp Function
or without worksheet formulae
myVar = (2.1+1)*10\10 -- HTH Bob Phillips "LSB" wrote in message ... I would like to use this function in my macro. As I found this function in the Excel Help, but when I use it in thecoding it prompts me the error message 'Sub or Function not Defined'. I would like to know how can I work on this error. Actually I want to round up my figure, for example 2.1 roundup to 3 3.5 roundup to 4 6.9 roundup to 7 Ccan please somebody help me on this. Thanks in advance. |
RoundUp Function
But does it work for 2.9?
-- HTH Bob Phillips "Thomas" wrote in message ... How about, var = CLng(2.1) + 1 Bob Phillips wrote: or without worksheet formulae myVar = (2.1+1)*10\10 -- HTH Bob Phillips "LSB" wrote in message ... I would like to use this function in my macro. As I found this function in the Excel Help, but when I use it in thecoding it prompts me the error message 'Sub or Function not Defined'. I would like to know how can I work on this error. Actually I want to round up my figure, for example 2.1 roundup to 3 3.5 roundup to 4 6.9 roundup to 7 Ccan please somebody help me on this. Thanks in advance. |
RoundUp Function
or even
2.9 \ 1 -- HTH Bob Phillips "Thomas" wrote in message ... Int(2.9) + 1 Bob Phillips wrote: But does it work for 2.9? -- HTH Bob Phillips "Thomas" wrote in message ... How about, var = CLng(2.1) + 1 Bob Phillips wrote: or without worksheet formulae myVar = (2.1+1)*10\10 -- HTH Bob Phillips "LSB" wrote in message ... I would like to use this function in my macro. As I found this function in the Excel Help, but when I use it in thecoding it prompts me the error message 'Sub or Function not Defined'. I would like to know how can I work on this error. Actually I want to round up my figure, for example 2.1 roundup to 3 3.5 roundup to 4 6.9 roundup to 7 Ccan please somebody help me on this. Thanks in advance. |
RoundUp Function
For that particular number, Int(2.9) + 1 and 2.9 \ 1 give the same result. But that's not true
if the number is 2.1. If the OP wants to always round up, the division won't work for fractional parts < 0.5, and the first formula is flawed for whole numbers. Int(2) + 1 = 3. If I interpret the question correctly, the result should be 2. Maybe this will do it Function RoundUp(x As Double) Dim y As Double y = Int(x) If y = x Then RoundUp = y Else RoundUp = y + 1 End If End Function On Fri, 8 Aug 2003 19:03:31 +0100, "Bob Phillips" wrote: or even 2.9 \ 1 |
All times are GMT +1. The time now is 11:48 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com