How to use the SGN function [VBA]
The SGN function returns an integer that shows the sign of the number.
Argument | SGN returns |
Number greater than 0 (zero). | 1 |
Number equal to 0 (zero). | 0 |
Number less than 0 (zero). | -1 |
Excel Function VBA Syntax
SGN(number)
Arguments
number | Required. Any valid numeric expression. If number is 0 (zero) then 0 (zero) is returned. |
Comments
I used the following macro to show how the SGN function behaves with different numerical values demonstrated in the picture above.
Sub Macro1() For Each cell In Range("B3:B12") cell.Offset(, 1) = SGN(cell.Value) Next cell End SubMore than 1300 Excel formulas
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form