Apply ABS function in VBA Excel

abs function vba excel absolute

Objective

To apply the ABS function in excel cells using VBA Excel.

Approach

Here we are applying ABS function in column B as shown in the image below. ABS function determines the absolute value of a number, which means how far is number from zero. For example, absolute value of -15 is 15, which represents how far is -15 from 0. Absolute value is never negative.In the code below we are looping through row 2 to row 5.We are applying the ABS formula in column B.

Code

Sub FindAbsoluteValue()
For i = 2 To 5
'Apply ABS formula in cloumn B
Range("B" & i).Formula = "=ABS(" & "A" & i & ")"
Next i

End Sub

 

In the image below we can see that absolute value of -10 is 10, while absolute value of 2 is 2.

 

abs function vba excel absolute

 

Reference

https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/abs-function

 

Post you may like

Apply Countifs function in VBA Excel