MS Excel: ABS Function (WS, VBA)
In Microsoft Excel, the ABS function returns the absolute value of a number.
The syntax for the ABS function is:
ABS( number )
number is a numeric value.
- Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000
Type of Function
- Worksheet function (WS)
- VBA function (VBA)
Worksheet Function Example
Let's take a look at an example to see how you would use the ABS function in a worksheet:
Based on the Excel spreadsheet above, the ABS function would return the following:
|=ABS(A1)||would return 210.67|
|=ABS(A2)||would return 2.9|
|=ABS(A3)||would return 3|
|=ABS(-4.5)||would return 4.5|
|=ABS(-210.67)||would return 210.67|
|=ABS(5)||would return 5|
|=ABS(2-10)||would return 8|
VBA Function Example
The ABS function can also be used in VBA code. For example:
Dim LNumber As Double LNumber = Abs (-210.6)
In this example, the variable called LNumber would now contain the value of 210.6.