Home Privacy Policy Feedback Link to us Site Map Forums

Excel: Sgn Function (VBA only)


In Excel, the Sgn function returns the sign of a number (represented as an integer).

The syntax for the Sgn function is:

Sgn ( number )

number is the the number to return the sign for.


Note:

If number is greater than zero, the Sgn function will return 1.

If number is equal to zero, the Sgn function will return 0.

If number is less than zero, the Sng function will return -1.


Applies To:

  • Excel 2007, Excel 2003, Excel XP, Excel 2000

For example:

Sgn(-123.67) would return -1
Sgn(0) would return 0
Sgn(123.67) would return 1

VBA Code

The Sgn function can only be used in VBA code. For example:

Dim LResult As Integer

LResult = Sgn(56)

In this example, the variable called LResult would now contain the value of 1.