+ Reply to Thread
Results 1 to 3 of 3

Forcing decimal places dependant on variable

Hybrid View

  1. #1
    Registered User
    Join Date
    05-04-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Forcing decimal places dependant on variable

    Hi all,

    I have a spreadsheet where I add a % and a total mass, and the sheet generates a weight for that %. The issue arrises when I weigh it out using different methods. I want to specify to be accurate and use 2 decimal places for small weights, or use none for large weights.

    I'm happy to have a drop menu to select the level of accuracy, but when i say 5% of 20kg I get 1kg. If I ROUND(A1,2) (for high accuracy) I get 1.00kg, which is great.

    I then want to use 1.00 in a concatenate, but it always reverts to 1

    tl;dr: What I need is a way of treating a number generated with no decimal places as one with either 0, 1 or 2 decimal places for use in a subsequent concatenate

    I'm sorry if this is not sufficiently clear. The book that I am working with has a lot going on around this issue, but I could write a sheet isolating this issue if it is required for clarity
    Last edited by NathM; 05-04-2011 at 05:35 PM.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: Forcing decimal places dependant on variable

    Hi,

    Could you make use of the =FIXED() function?

    In your example, =FIXED(1,2) would return 1.00, and

    =CONCATENATE(FIXED(1,2),"kg") would return 1.00kg
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    05-04-2011
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Forcing decimal places dependant on variable

    Excelent Sweep, I love an elegant solution.

    I was able to =FIXED() the cells that feed into the concatenate based on desired accuracy, and then concatenate that fixed value and preserve it.

    Thanks again, much appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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