+ Reply to Thread
Results 1 to 4 of 4

Adjusting decimals in a range of numbers to a set decimal value

  1. #1
    Registered User
    Join Date
    03-21-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    3

    Adjusting decimals in a range of numbers to a set decimal value

    I have a long list of prices all with different last 2 digits (the cents value) and I would like to assign all numbers with the last 2 digits within a certain range a new last 2 digits value

    For example, I would like to assign all numbers in the group 2.19, 17.13, 28.04, 21.27 to all finish with the last 2 digits .29 so the result would be 2.19 becomes 2.29, 17.13 becomes 17.29, 28.04 becomes 28.29 and 21.27 becomes 21.29

    At the same time, in the same price list I have a bunch of values that end between .30 and .49 and I would like to assign all of these to end in .49, so 2.34 becomes 2.49 and 76.44 becomes 76.49, etc

    Essentially I think I want to group prices in a range (based on the last two digits) and then assign a new set of last two digits to all prices in that set? Does anyone know of a way to do this in Excel or VBA?
    Thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Adjusting decimals in a range of numbers to a set decimal value

    Welcome to the forum.

    Please Login or Register  to view this content.
    The formula in B1 and down is

    =INT(A1) + LOOKUP(MOD(A1,1), {0,30}%, {29,49}%)
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-21-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Adjusting decimals in a range of numbers to a set decimal value

    Thanks for the quick answer - its great.
    If you could help me with one follow on question so I understand the logic, what would the command look like if I wanted to change all values between X.00 and X.29 as X.29, all the values between X.30 and X.49 as X.49 and all the values between X.50 and X.99 as X.99

    Thanks again, and I appreciate the welcome.

  4. #4
    Registered User
    Join Date
    03-21-2012
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Adjusting decimals in a range of numbers to a set decimal value

    Thanks, I tinkered a bit and figured it out.
    Thanks again

+ 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