Excel ABS Function
The Excel ABS function returns the absolute value of a number
Example: Excel ABS Function
=ABS(-115)
|
Result in cell C5 (115) - returns an absolute value of -115, therefore, it converts a negative to a positive number.
|
=ABS(115)
|
Result in cell C6 (115) - returns the same number as entered into the function, given the value is already a positive number.
|
=ABS(B5)
|
Result in cell C5 (115) - returns an absolute value of the number in cell B5, therefore, it converts a negative to a positive number.
|
=ABS(B6)
|
Result in cell C6 (115) - returns the same number that is captured in cell B6, given the value is already a positive number.
|
METHOD 3. Excel ABS function using the Excel built-in function library with hardcoded values
EXCEL
Formulas tab > Function Library group > Math & Trig > ABS > populate the input box
=ABS(-115) Note: in this example we are converting -115 into a positive number. |
METHOD 4. Excel ABS function using the Excel built-in function library with links
EXCEL
Formulas tab > Function Library group > Math & Trig > ABS > populate the input boxes
=ABS(B6) Note: in this example we are converting the number captured in cell B5 (-115) into a positive number. |
Sub Excel_ABS_Function()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("ABS")
'apply the Excel ABS function
ws.Range("C5") = Abs(-115)
ws.Range("C6") = Abs(115)
ws.Range("C5") = Abs(-115)
ws.Range("C6") = Abs(115)
End Sub
OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named ABS.
Worksheet Name: Have a worksheet named ABS.
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell references ("C5") and ("C6") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Sub Excel_ABS_Function()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("ABS")
'apply the Excel ABS function
ws.Range("C5") = Abs(ws.Range("B5"))
ws.Range("C6") = Abs(ws.Range("B6"))
ws.Range("C5") = Abs(ws.Range("B5"))
ws.Range("C6") = Abs(ws.Range("B6"))
End Sub
OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named ABS.
Numbers: If using the exact same VBA code you need to ensure that the numbers that you want to be returned as absolute values are to be captured in range ("B5:B6").
Worksheet Name: Have a worksheet named ABS.
Numbers: If using the exact same VBA code you need to ensure that the numbers that you want to be returned as absolute values are to be captured in range ("B5:B6").
ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell references ("C5") and ("C6") in the VBA code to any cell in the worksheet, that doesn't conflict with the formula.
Numbers: Select the numbers for which you want to return absolute values by changing range ("B5:B6").
DESCRIPTION
The Excel ABS function returns the absolute value of a number. Therefore, using this function you can convert a negative number to a positive number. A positive number will remain unchanged.
The Excel ABS function returns the absolute value of a number. Therefore, using this function you can convert a negative number to a positive number. A positive number will remain unchanged.
SYNTAX
=ABS(number)
=ABS(number)
ARGUMENTS
number: (Required) A numeric value to be calculated as an absolute value.