# VBA ABS Function

Home ➜ VBA Functions LIST (Category Wise) ➜ **How to use the VBA ABS Function (Syntax + Example)**

## What is VBA ABS Function

The VBA ABS function is listed under the math category of VBA functions. When you use it in a VBA code, **it returns an absolute number in the result**. In simple words, it returns a non-negative number that means if you specify a negative number it will remove its sign and returns it in the result.

## how to use it

To use VBA's ABS function you need to understand its syntax and arguments:

### Syntax

**Abs(Number)**

### Arguments

**Number**: The number which you want to convert into an absolute value (number).

## Example to use ABS Function in VBA

To practically understand how to use VBA ABS function, you need to go through the below example where we have written a VBA code by using it:

```
Sub example_ABS()
Range("B1").Value = Abs(Range("A1"))
End Sub
```

```
Sub myMacro()
Dim myText As String
myText = "Puneet"
MsgBox MyTxt
End Sub
```

In the above example, we have used the value from the cell A1 where we have a negative number (-1029) and then we have used the ABS function to convert that value into an absolute number and enter that value in the cell B1.

So basically when you run this code it simply takes the value from the cell A1 and converts it into an absolute number.

## Notes

Below are some important points which you need to take care while using ABS function in VBA.

- If the value specified is a value other than a number or a number which can’t be recognized as a number, VBA will return the run-time 13 error.
- If the value supplied is NULL then it will return a NULL in the result.

About the Author

Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.