Need to convert numbers to text in a specific format
Hi all, thanks in advance
I work in the inventory of a retail store where we need to print the cost of our product on our barcode, but in our own text code. For example, our code is the word "Phone Diary" where P is 1, H is 2 and so on till Y is 0. So if the cost of our product is 457 the code we write on our barcode is NEI.
The only exception to the rule is when the cost of the product has consecutive number like 1668 then the second consecutive number is replaced with an X, so 1668 would be PDXA
just some random numbers with what their codes would be
346 OND
15558 PEXXA (multiple consecutive are all X )
9985 RXAE
1004 PYXN
1002 PYXH
sometimes we receive bills to barcode which have 200-300 products with different costs so it takes a long time to translate the costs to codes. Is there any way to formulate this ? Im a complete excel noob and have been learning basic functions online. I tried to make something with the (IF, Then) functions but i got lost, im sure there should be a better way to do it.
Just for Clarification ( P = 1, H = 2, O = 3, N = 4, E = 5, D = 6, I = 7, A = 8, R = 9, Y = 0, Consecutive number = X )
It would be possible for me to make a table of numbers from 1 to 1000 and the letters that represent them, but we do get products that cost upto 6000-7000 (INR) and it wouldnt be possible for me to make a sheet with all numbers and their codes upto 7000
Posted Apr 20, 2021, 6:42 AM UTC · edited
Assuming your version of Excel has TEXTJOIN, try this and see if it does what you're looking for:
Assumes numbers are in A (starting A2), and you've setup your PHONE DIARY code conversion table in D2 thru E12 (w/X being listed/included).
Sample of results (gray cells have formula copied down): https://imgur.com/IaaUkWp
NOTE: You could setup your PHONE DIARY conversion chart on a whole other sheet and call the ranges from there instead if you wanted to.
SOLUTION VERIFIED
You have awarded 1 point to mh_mike
^I ^am ^a ^bot, ^please ^contact ^the ^mods ^with ^any ^questions.
In case you want, you could also do it with CONCAT (if you've got TEXTJOIN, you'll also have CONCAT):
Since we're not plugging in any separators, we don't really need to use TEXTJOIN.
Also, if you plan to copy that formula down past where data might end on (or might not-yet-be typed or pasted into) the A column -- we can wrap the whole thing inside an IF checking if there is something in A to convert. If so, convert normally, otherwise leave an empty "" blank behind. If you want/need that, here's how to do it:
mate you're an absolute wizard, thankyou so much
Could you guide me on how to set up the code on another page and reference it from there ?
Sure, just set that legend up on some other sheet in columns A and B (just like you saw them in D and E on the sample screenshot I showed earlier).
For example purposes, I set it up in columns A and B on a sheet named PDC (standing for
PhoneDiaryConversion). You could name the sheet anything you want -- just change thePDC!prefixes you'll see in the following formula accordingly:For TEXTJOIN:
For CONCAT:
Truly an advanced user, I aspire to reach your level of competency one day!
haha Thanks :) (but don't confuse years upon years of experience in a particular craft with full-on competency in other areas of Excel -- there's plenty of stuff I'm still learning about)
I just work with text (data cleaning) a lot, and trying to figure these kinds of things out probably intrigues me waaaaaay too much! haha