The Excel Abs function returns the absolute value of a number i.e. without its sign (-). If the number is positive (+) it returns the same, if it is negative (-) it will return the positive value (+).
Excel Abs Function Syntax
The syntax of this function is very simple:
Abs( Number )
where
- Number – is a number (integer, float, double, currency) that you want to convert to an absolute value.
Examples
=ABS(10) 'Result: 10 =ABS(-5) 'Result: 5 =ABS("-5") 'Result: 5 =ABS(12.1) 'Result: 12.1
As you can see the Excel Abs function manages easily with converting strings to numbers and turning them into their absolute values.
Excel Absolute Value in VBA
The equivalent in Excel VBA of the ABS function is the Application.WorksheetFunctions.Abs function.
Debug.Print Application.WorksheetFunctions.Abs(-10) 'Result:10