+ Reply to Thread
Results 1 to 18 of 18

Need formula for substracting the number “9” to each number inside a long number and more.

  1. #1
    Registered User
    Join Date
    05-13-2016
    Location
    Argentina
    MS-Off Ver
    2007
    Posts
    8

    Need formula for substracting the number “9” to each number inside a long number and more.

    I want you to have some fun. I need something specific.

    First i must explain what i do. I use a simple codification for product prices at retail store, because i dont want people know the real price for themselves. So i change the original numbers to another substracting the number 9 for each number. Normally I manually write down all the prices with this codification for every product.

    So.. for example number 10 would be 89. (9-1 = 8) and (9-0 = 9) Other examples:

    $128 = 871
    $75 = 24
    $236 = 763
    $9 = 0
    Finally i put 2 number nines (9) at the beginning of the codified price also, to confuse people who might think that number could be the price.

    So the examples i used before are like this:

    99871 (means $128)
    9924 (means $75)
    99763 (means $236)
    990 (means $9)
    Remember that i need 2 (two) nines before the real price. The real prices never start with 0 so, the nines are the begginning are only for confuse people.

    Ok. So, now that you understand, here comes the 2nd part. I have an excel whith hundreds of my products added, with prices, description, etc. And i decided it is time to use a printer and start to print this information from excel. I have a software to do that, but first i need to have the codified prices in the excel also.

    The fun part begins when i want to convert the real prices that are already written in my excel document into a new column AUTOMATICALLY. So that way i don΄t have to type again all the prices in codified form for the old and new items i add in the future.

    Can someone help me with this? Is it even possible?

    I tried with =A1-9999 but, it works well with 2 character number only. Because if the real price is 5, i will get 3 nines: 9994(code). And if the price is 234 i will get only 1 nine 9765(code). And it is a condition i need to have the TWO nines at first.

    Thank you very much in advanced!

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    1.If the real price in B2 , converted

    ="99"&10^LEN(B2)-1-B2

    2. Converted to real price

    =10^(LEN(A2)-2)-1-RIGHT(A2,LEN(A2)-2)
    Last edited by Phuocam; 05-13-2016 at 10:51 PM.

  3. #3
    Registered User
    Join Date
    05-13-2016
    Location
    Argentina
    MS-Off Ver
    2007
    Posts
    8

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    @Phuocam
    Thanks for your answer.
    First, i didnt know where exactly put that, but i tried using an empty sheet, pasting the formula in any cell and gives me an error.

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    See attached
    Attached Files Attached Files
    Last edited by Phuocam; 05-13-2016 at 11:03 PM.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    Very neat

    List your values (examples) in column B, starting in B2. The first formula goes in cell A2, the second in cell C2. Then just copy them down.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    @ TMS
    Thank you!

  7. #7
    Registered User
    Join Date
    05-13-2016
    Location
    Argentina
    MS-Off Ver
    2007
    Posts
    8

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    @Phuocam
    You are a genius man.
    Thanks for the file and your time!
    I have a last question. Real and converted columns are just what i need.
    Do i need column 3 formula for something? Or its just you did it at reverse also?
    Last edited by walpap; 05-13-2016 at 11:29 PM.

  8. #8
    Registered User
    Join Date
    05-13-2016
    Location
    Argentina
    MS-Off Ver
    2007
    Posts
    8

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    @Phuocam
    I know this is an excel forum, but i did a test right now. And i uploaded the file to google spreadsheets, because its useful to me to have it there also.
    It works but, there is a small difference in the results. What happen is that in the converted number it shows 6 nines at the beginning instead of just 2.
    Maybe there is a simple solution for it and you know it? Or i just have to go to a google forum.
    Thanks!

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    Edit formula in B2 post #4

    ="99"&10^LEN(INT(A2))-1-A2

    in C2:

    =10^(LEN(INT(B2))-2)-1-RIGHT(B2,LEN(B2)-2)

    Hope this helps!

  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
    52,929

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    http://www.mrexcel.com/forum/excel-q...mber-more.html
    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

  11. #11
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,409

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    This is the formula I came up with and posted over in my home forum (MrExcel) where the OP cross-posted his question to (I sure hope he reads FDibbins' message in Post #10)....

    =IFERROR(0+(99&REPT(9,LEN(A1))-A1),"")

    Note that this formula outputs the empty string ("") for non-numeric values in the referenced cells.

  12. #12
    Registered User
    Join Date
    05-13-2016
    Location
    Argentina
    MS-Off Ver
    2007
    Posts
    8

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    I am really sorry guys. I should have read the rules first, but i didn΄t.
    As FDibbins said, i posted the same question in other forum. (I didnt know there was the same people in both places, and also didnt expect feedback this fast.

    So here is the link for the same question in other forums:
    http://www.mrexcel.com/forum/excel-q...mber-more.html

    I am aware now.

    I will try all possible formulas and solution and then i will answer which worked better for me. Until now i tried Phuocam xls in excel and it worked great!

    Thanks to everyone!

  13. #13
    Registered User
    Join Date
    05-13-2016
    Location
    Argentina
    MS-Off Ver
    2007
    Posts
    8

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    I see someone removed the duplicated post. Now if you wish you can remove this comment also.
    I dont know how to do it.
    Last edited by walpap; 05-14-2016 at 02:51 AM.

  14. #14
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    You're welcome, good luck!

  15. #15
    Registered User
    Join Date
    05-13-2016
    Location
    Argentina
    MS-Off Ver
    2007
    Posts
    8

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    @Phuocam
    Im sorry to bother you again but i realize there is a small issue with the formula.
    It doesn΄t well when the price numbers start with ninety or ninehundred something.. for example 90, or 98 or 904.
    In those cases it only converts the numbers after the 9.

    So, when the real price is 90 it converts to 999, when it should be 9909.
    Or when the price is 904 it converts it to 9995 when it should be 99095.

    It seems it has something to do with the nine not being convert to zero number.

    Do you know what could be the reason?

  16. #16
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    Try again...

    =10^(LEN(INT(A2))+2)-1-A2
    Last edited by Phuocam; 05-16-2016 at 01:16 AM.

  17. #17
    Registered User
    Join Date
    05-13-2016
    Location
    Argentina
    MS-Off Ver
    2007
    Posts
    8

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    Yeah! It worked.

    I really, REALLy, appreciate all your help.

    Again.. thank you very much!

  18. #18
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Need formula for substracting the number “9” to each number inside a long number and m

    You're welcome!

+ 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. Formula to determine IF a value has a specific number inside it
    By StephenTroup in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-06-2015, 06:47 PM
  2. [SOLVED] Change one number in a cell inside a formula to a variable that is getting higher (+1)
    By chablo309 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2015, 07:28 AM
  3. How to get a number show up as 0 inside a formula.
    By mlbdc2012 in forum Excel General
    Replies: 11
    Last Post: 02-10-2015, 09:50 AM
  4. [SOLVED] Formula/Macro to list down the dates that are inside a week number of a month
    By michaljireht in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-22-2014, 08:16 AM
  5. Number format to Display 20 character long number.
    By SamCV in forum Excel General
    Replies: 6
    Last Post: 07-09-2014, 08:19 PM
  6. Formatting a number inside a formula
    By bopsgtir in forum Excel General
    Replies: 3
    Last Post: 10-28-2011, 09:21 AM
  7. Substracting a fixed number of hours to a time
    By PauloCR in forum Excel General
    Replies: 5
    Last Post: 09-19-2006, 09:26 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