You can use this event code to do that (it also includes a T for terabytes,
just in case). To implement this code, right click the tab at the bottom of
the worksheet and select View Code from the popup menu that appears, then
copy/paste the following into the code window that opened up...
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C:C")) Is Nothing Then
If Target.Value < 1000 Then
Target.NumberFormat = "0"
ElseIf Target.Value < 999500 Then
Target.NumberFormat = "0.000, \K"
ElseIf Target.Value < 999500000 Then
Target.NumberFormat = "0.000,, \M"
ElseIf Target.Value < 999500000000# Then
Target.NumberFormat = "0.000,,, \G"
Else
Target.NumberFormat = "0.000,,,, \T"
End If
End If
End Sub
Since you didn't tell us what cells, I assumed Column "C"; change the Range
inside the Intersect function to the cell range you want to have this
functionality (use Cells instead of a Range call if you want this
functionality to apply everywhere on the worksheet). Also, since you didn't
mention it, I chose to display 3 decimal places after the decimal point for
numbers with a suffix. After implementing the above code, any numbers
entered into those cells will adopt the number format you requested. Note
that existing numbers will not change unless re-entered. You can do that one
at a time or you can select all the existing numbers and execute this code
from the Immediate Window...
Selection.Formula = Selection.Formula