# VBA SGN Function

HomeVBA Functions LIST (Category Wise)How to use the VBA SGN Function (Syntax + Example)

## What is VBA SGN Function

The VBA SGN function is listed under the math category of VBA functions. When you use it in a VBA code, it returns the arithmetic sign of an integer. In simple words, it returns +1 for a positive number, -1 for a negative number, and a 0 for the zero.

## how to use it

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

Sgn(Number)

### Arguments

• Number: An integer to specify the number that you want the arithmetic sign of.

## Example to use SGN Function in VBA

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

```Sub example_SGN()
Range("B1").Value = Sgn(Range("A1"))
End Sub```

In the above code, we have used the SGN to get the arithmetic sign and it has returned 1 as we have a positive number in the cell A1.

## Notes

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

• If the value specified is a value other than a number or a number that can’t be recognized as a number, VBA will return the run-time 13 error.