ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ABS Excel Function (https://www.excelbanter.com/excel-programming/287099-abs-excel-function.html)

PEdro

ABS Excel Function
 
Hi
ABS excel function is not available in Visual Basic.
What code should I write in order to give me the absolute number

Regards
PEdro



Bob Phillips[_6_]

ABS Excel Function
 
Pedro,

Use the Abs VB function

myVar=Abs(-50.3)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pedro" wrote in message
...
Hi
ABS excel function is not available in Visual Basic.
What code should I write in order to give me the absolute number

Regards
PEdro





shades

ABS Excel Function
 
ABS is a VBA function (see Walkenbach, -Excel 2002 PowerProgramming-,
page 871)

Just to test it, try this: put a number in cell F6, then use this code
to put absolute value into F7. (Shorter way to do this, but gives you
the idea).


Code:
--------------------

Sub Test()
Dim i As Integer
i = Range("F6").Value
Range("F7").Value = Abs(i)
End Sub

--------------------



---
Message posted from http://www.ExcelForum.com/


KJTFS[_12_]

ABS Excel Function
 
if you dont want to use the function then

dim x as double
dim abs as double

if x < 0 then
abs = x * -1
else
abs = x
endif

Keith
www.kjtfs.com

shades wrote:
[b]ABS is a VBA function (see Walkenbach, -Excel 200
PowerProgramming-, page 871)

Just to test it, try this: put a number in cell F6, then use thi
code to put absolute value into F7. (Shorter way to do this, bu
gives you the idea).


Code
-------------------

Sub Test()
Dim i As Integer
i = Range("F6").Value
Range("F7").Value = Abs(i)
End Sub

-------------------
[/B


--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com