From a previously posted answer of mine to an almost identical question...
Format cells for KB, MB, GB, etc....
You can't do that with straight cell formatting, but you can implement it using event 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...
Code:
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 \B"
ElseIf Target.Value < 999500 Then
Target.NumberFormat = "0.000, \K\B"
ElseIf Target.Value < 999500000 Then
Target.NumberFormat = "0.000,, \M\B"
ElseIf Target.Value < 999500000000# Then
Target.NumberFormat = "0.000,,, \G\B"
Else
Target.NumberFormat = "0.000,,,, \T\B"
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). After doing this, 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