I have a macro that formats numbers to 3 significant figures using elseif statements. It works great on positive number, but I need to format negative numbers also (-1 should be -1.00). How do I modify my code to include negative numbers?
[vba]Dim rCell As Range
For Each rCell In Selection
If rCell.Value = 0 Then
rCell.NumberFormat = "0"
ElseIf rCell.Value < 0.001 Then
rCell.NumberFormat = "0.000000"
ElseIf rCell.Value < 0.01 Then
rCell.NumberFormat = "0.00000"
ElseIf rCell.Value < 0.1 Then
rCell.NumberFormat = "0.0000"
ElseIf rCell.Value < 1 Then
rCell.NumberFormat = "0.000"
ElseIf rCell.Value < 10 Then
rCell.NumberFormat = "0.00"
ElseIf rCell.Value < 100 Then
rCell.NumberFormat = "0.0"
ElseIf rCell.Value < 1000 Then
rCell.NumberFormat = "0"
End If
Next rCell[/vba]
Thanks for the help (again!)