+ Reply to Thread
Results 1 to 11 of 11

Roundup and add leading zeros if less than 100 in a referenced cell from a range

  1. #1
    Registered User
    Join Date
    10-01-2020
    Location
    London, England
    MS-Off Ver
    365
    Posts
    78

    Roundup and add leading zeros if less than 100 in a referenced cell from a range

    Hi experts,

    I have a specific requirement where I have a range list to select a number, from 1 to 150.
    This value is then selected and used in the contents of another cell.
    This is simple enough. I also need to use it in another cell but rounded up to the next 10, also simple enough.
    What I can't find out, is how to get to to 3 digits, leading with zeros.
    So 1 would become 010 (rounded up).
    15 would become 020
    105 would be 110
    Then add in a word from another range and piece these two together in another cell in the perfect format...
    030 Goats if I select "25" and "Goat"
    etc.
    See attached for this.
    Also, how to add a plural if > 1?
    In this scenario, it will always be more than one, but for reference, how could it add plural if it didn't round up?
    Attached Files Attached Files

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

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    You can do it like this:

    =TEXT(ROUNDUP(E3,-1),"000")&" "&E4&"s"

    Note that some plurals do not just have "s" added on to the singular noun (like Fish).

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    10-01-2020
    Location
    London, England
    MS-Off Ver
    365
    Posts
    78

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    That's great, thanks for that swift response. Perfectly answered my problem.

    Though with the added "s", it will always add it if the select is more than 1.
    I.E. 1 Apples
    It should be:
    - 1 Apple
    - 5 Apples
    etc ...

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    But you are always rounding up to the nearest 10 so even if the number were 1, it would become 10.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,129

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    If 1 is to become 010... how will you ever get a result of 001, thus requiring a singular unit of measure (orange, or whatever...)?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  6. #6
    Registered User
    Join Date
    10-01-2020
    Location
    London, England
    MS-Off Ver
    365
    Posts
    78

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    In this scenario, it will always be more than one, but for reference, how could it add plural if it didn't round up?

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,129

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    Without the roundup:

    =TEXT(E3,"000")&" " &E4&IF(E3>1,"s","")

  8. #8
    Registered User
    Join Date
    10-01-2020
    Location
    London, England
    MS-Off Ver
    365
    Posts
    78

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    Sublime support, Thanks All.

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,129

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

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

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    And how would you deal with words like Sheep or Foot ?

    Pete

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,129

    Re: Roundup and add leading zeros if less than 100 in a referenced cell from a range

    The joys of a horrendously irregular language.

+ 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. [SOLVED] Format Cell to Text and Add Leading Zeros
    By hnguy71 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2018, 02:17 PM
  2. combine cells where one cell has leading zeros
    By galetondesigns in forum Excel General
    Replies: 7
    Last Post: 09-20-2012, 04:20 PM
  3. formatted cell with leading zeros
    By ssdsibes in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-08-2009, 08:10 PM
  4. Add leading zeros to existing data in a cell
    By jpartney in forum Excel General
    Replies: 1
    Last Post: 03-19-2008, 02:08 PM
  5. [SOLVED] Format a cell to keep leading zeros.
    By Shadyhosta in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-27-2005, 11:37 AM
  6. [SOLVED] How do I force leading zeros in an Excel cell?
    By EricKei in forum Excel General
    Replies: 2
    Last Post: 06-15-2005, 04:05 PM
  7. Replies: 1
    Last Post: 05-04-2005, 02:06 PM

Tags for this Thread

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