+ Reply to Thread
Results 1 to 11 of 11

Supressing zeros in number columns when no decimal values are entered

  1. #1
    Registered User
    Join Date
    07-14-2015
    Location
    FL
    MS-Off Ver
    2013
    Posts
    5

    Supressing zeros in number columns when no decimal values are entered

    Hi everyone.

    I have a column whose datatype is number set to two decimal places. Everyone knows what this means is, that each cell in that column will always show two decimal places. That's fine when the values entered happen to have decimals. But, what if I wanted to format the column such that only the values entered are shown?

    For example, if a user entered 3, then I want the display to read 3. If the user entered 4.2 then I want the display to read 4.2. And if the user enters 6.13 then the value displayed should read 6.13. I'll be doing some math on these numbers so I'm guessing it's best to leave the datatype as a number and not change it to say, text.

    Does anyone know how I can do this?

    Thanks!

    KJ

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Supressing zeros in number columns when no decimal values are entered

    Hi.

    Not sure I understand. What restrictions are there that you haven't mentioned which prevents the format simply being set to General?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,044

    Re: Supressing zeros in number columns when no decimal values are entered

    Hi, welcome to the forum

    Try setting the format to General
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    07-14-2015
    Location
    FL
    MS-Off Ver
    2013
    Posts
    5

    Re: Supressing zeros in number columns when no decimal values are entered

    Hi XOR LX.

    I want the field to be numeric because I'll be doing some calculations on the values entered in the column. It seemed appropriate to keep the column's datatype a number, rather than general. I thought that if I kept the column a numeric datatype, I wouldn't get into any trouble or encounter any weird, strange behavior by trying to do calcs with a non-numeric field.

    Just trying to be on the safe side here.

  5. #5
    Registered User
    Join Date
    07-14-2015
    Location
    FL
    MS-Off Ver
    2013
    Posts
    5

    Re: Supressing zeros in number columns when no decimal values are entered

    Hi, FDibbins. Glad to be here.

    I wanted to avoid any funky one-off instances of getting into trouble by doing calcs on a non-numeric field. I've run into this before (not in Excel) and I thought it'd be best to keep numbers formated as numbers.

    Are you aware of any situation - however odd or uncommon, where the results could be off somehow if I did calcs on a field whose datatype was General?

    Thanks.
    KJ

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Supressing zeros in number columns when no decimal values are entered

    Can you give an example of such "weird, strange behavior" that might occur with a range formatted as General but which would be avoided if the format were instead Number?

    Regards

  7. #7
    Registered User
    Join Date
    07-14-2015
    Location
    FL
    MS-Off Ver
    2013
    Posts
    5

    Re: Supressing zeros in number columns when no decimal values are entered

    I cannot, off hand. I have run across this kind of thing before (not with Excel) where, using data that looks like a number but is really text (or some other format) can sometimes not give expected results. It's not at all common, but you know what they say. Once bitten...

    Can you foresee any situation where doing calcs on numbers in cells formatted as General would cause a problem, however remote?

    Thanks.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Supressing zeros in number columns when no decimal values are entered

    Quote Originally Posted by KJay View Post
    Can you foresee any situation where doing calcs on numbers in cells formatted as General would cause a problem, however remote?
    Not that wouldn't also occur if that format were set to anything else.

    Typing '1.2 (with a leading apostrophe) into a cell formatted as Number (set to as many decimal places as you like) will not mean that that entry is considered any more numeric (it will not be) than if I'd entered it into a cell formatted as General.

    Regards

  9. #9
    Registered User
    Join Date
    07-14-2015
    Location
    FL
    MS-Off Ver
    2013
    Posts
    5

    Re: Supressing zeros in number columns when no decimal values are entered

    Excellent to know. Ok then. General it is!

    Thank your for the exceptionally quick responses.

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,044

    Re: Supressing zeros in number columns when no decimal values are entered

    General format is just that - it will accept pretty much any input, and display as entered. If you enter a number, it will display exactly as entered...if you enter text, that too will be displayed as entered.

    If you, for instance, have a column where some cells are text, and others numeric entries, only the numbers will be added with =SUM()

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,408

    Re: Supressing zeros in number columns when no decimal values are entered

    Yes, there can be problems, like the formula =C2*2 will return 0 if C2 is empty but will return the #VALUE error if you put a space in C2, even though it looks the same. However, the formatting of C2 has no bearing on that result in these two cases. I think what you might be thinking of is applying data validation to ensure that only numbers can be entered, so that subsequent calculations will not cause that type of mismatch error. That's a different thing than formatting.

    Hope this helps.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Format cells to add 3 zeros before my entered number
    By BADebbie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-30-2015, 11:44 AM
  2. [SOLVED] Removing Leading Zeros, maintaining zeros after decimal
    By Waycool86 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-17-2015, 01:15 PM
  3. Keep number format when converting to text - with decimal and zeros
    By tampagirl in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-11-2014, 06:34 PM
  4. Replies: 5
    Last Post: 01-28-2013, 07:29 PM
  5. Replies: 1
    Last Post: 04-09-2012, 02:58 PM
  6. columns in excel to reflect array of values entered in previous two columns
    By netvasi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2011, 01:12 AM
  7. [SOLVED] number formats default to 2 decimal points when entered so 24 bec.
    By kiddo7us in forum Excel General
    Replies: 1
    Last Post: 03-30-2005, 05:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1