In short you can't - at least not with a single Custom Number Format as would appear to be the requirement.
You could use VBA Change Event to apply an appropriate Format based on significance of entry.
In XL2007 and above you can use a Conditional Format to alter Number Format - ie have a rule based on MOD of value with different number formats for whole values and those with decimal remainder.
For sake of ex. ... assume A1:A4 contain the values detailed in original post - with range selected apply rules of:
=INT(A1)=A1
set custom number format to General or # etc...
=MOD(A1,1)
set custom number format to that described in your original post
to reiterate the point though - this is not backwards compatible with versions prior to XL2007
Bookmarks