Microsoft Excel - How to give numerical value for multiple alphabet in one cell in excel

Asked By Anees
10-Jul-10 12:56 PM

how to give numerical value for multiple alphabet in one cell for excel

if i give 1520 in one cell the answer mustbe CEUD for example  c is 1 u2 (C1,U2,M3,B4,E5,R6,L7,A8,N9,0D)

Thanks

Anees

  R VENKAT replied to Anees
10-Jul-10 11:32 PM
solution given in the officesoftware forum
  bruce mcpherson replied to Anees
11-Jul-10 07:30 AM
Hello


good question. There are a few ways to do this. The simplest is probably to use substitute - assuming your value is in A1, this will fill down as required

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(A1,"1","C"),"2","U"),"3","M"),"4","B"),"5","E"),"6","R")
,"7","L"),"8","A"),"9","N"),"0","D")

However the slightly more interesting solution, (and more extensible), is to use an array formula. Unfortunately the built in Concatenate() function of Excel doesn't handle array formula, so the downside is you have to provide your own simple user defined function, which I enclose below. Remember to enter the array formula with control/shift/Enter. If you do it correctly { } brackets will appear.

The formula -

=afconcat(CHOOSE(1+MID(A1,(ROW(INDIRECT(1&":"&LEN(A1)))),1),
"D","C","U","M","B","E","R","L","A","N"))

and the user defined function

Function afConcat(arr() As Variant) As String
  Dim i As Long, s As String
  s = ""
  For i = LBound(arr) To UBound(arr)
    s = s & arr(i, 1)
  Next i
  afConcat = s
End Function

If anyone can think of how to use this array formula approach without having to use a user defined function, I'd be very interested to hear from you.

Bruce

  Anees replied to bruce mcpherson
11-Jul-10 11:38 AM

Thanks a ton boss, its working.

Regards

Anees

  Anees replied to bruce mcpherson
12-Jul-10 02:19 PM

Boss,

 

I have a similar case , but this time numeric to numeric as below 1 values 3, 2 as 6 ........, sorry for the trouble can you please help me again.

 

1-3,2-6,3-7,4-9,5-1,6-8,7-2,8-0,9-4,0- 5 .

Anees

  bruce mcpherson replied to Anees
13-Jul-10 09:00 AM
HI

On this one you are going need to use the 2nd method, with and array formula, and a user defined function. Please read how to that that in the previous response, and this time your formula would be

=afconcat(CHOOSE(1+MID(A1,(ROW(INDIRECT(1&":"&LEN(A1)))),1),
"5","3","6","7","9","1","8","2","0","4"))


If you have any more of these then i think you should be able to figure out the pattern - just put your output translation as above in order 0-9 as the 2nd argument of the choose function. Dont forget to ctrl/enter/shift instead of enter as you put the formula in. YOu can just fill down as normal after that

Bruce
  Mohammed replied to bruce mcpherson
13-Jul-10 11:20 AM

Hi,

 

Neither of the formulas working in Excel2003, only works in Excel2007 any other formula is there for Excel2003 , please advise.

Thanks in advance

 

Br

Ishaq

  bruce mcpherson replied to Mohammed
13-Jul-10 12:25 PM
Hello

I'm not sure if you are also Anees who asked the original question? 

Anyway for the 1st question, there is a nesting depth of 8  in excel 2003, so the substitute solution, with a depth of 10  won't work. You can however make it work with the use of a helper cell. Divide the problem in two.

Assuming your input is in in a1, put this in b1 (or some other out of the way column). this is your helper cell.

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(SUBSTITUTE(A1,"1","C"),"2","U"),"3","M"),"4","B"),"5","E"),"6","R")

and this, your final answer in c1

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1,"7","L"),"8","A")
,"9","N"),"0","D")

You can then hide helper column if you want.

The Array formula alternative should work in both 2003 & 2007 i believe, but i don't have 2003 to test it. Can you tell me more about the specific error in 2003.

Bruce
  Mohammed replied to bruce mcpherson
13-Jul-10 12:55 PM
Hi Bruce, 

Thanks for the swift reply , i am Ishaq not Anees how ever we know each other, he suggested me to rise the issue when i face the problem in 2003, the formula one, works well with 2007 which he uses but not for me since i am using 2003, honestly speaking i am trying to copy the array formula in excel and make it  work, its not functioning, can you please explain the way how to make the excel formula work in excel.thanks again.

Ishaq
U.A.E
  bruce mcpherson replied to Mohammed
13-Jul-10 04:02 PM
HI

the second one i sent where you split substitute in two will work in 2003. 

for the array formula you need to do two things

firstly create a module (user defined function) in visual basic - i assume you know how to do that? copy this code over  into the module you have created

Function afConcat(arr() As Variant) As String
  Dim i As Long, s As String
  s = ""
  For i = LBound(arr) To UBound(arr)
  s = s & arr(i, 1)
  Next i
  afConcat = s
End Function

if that worked then go back to the spreadsheet, go to the cell to contain the formula and copy this into your formula bar ( im assuming you have your value in A1)

=afconcat(CHOOSE(1+MID(A1,(ROW(INDIRECT(1&":"&LEN(A1)))),1),
"5","3","6","7","9","1","8","2","0","4"))

instead of the enter key, use control/shift/enter at the same time. curly brackets {} should appear round the formula. Did they?

What happened now? did you get an error ? 

Bruce

now once you have done that- while you are still in the formula bar

  Mohammed replied to bruce mcpherson
14-Jul-10 12:04 PM

Dear Mr.Bruce,

 

Thanks for all the help , i have seen your reply for Mr.Ishaq we are not same i recommended him to post the problem.  i have  2 more request on the same topic, and one is other.

1, will i be able to make a D or Q to precede the result (ie) if i give 12345 the result would be Dcumbe

2, on the A1 cell must not accecpt more than 5 character or numerics , it should accecpt 12345 only and the result must be (preceded by a D or Q ) Dcumbe. 

3, May i know about you - If possible

 

Please reply and help me

 

Thanks Again

Anees Ahamed

 

  Mohammed replied to bruce mcpherson
14-Jul-10 12:04 PM
Mr.Bruce

Thanks a lot. Its working well

Ishaq
UAE
  Mohammed replied to Mohammed
14-Jul-10 12:19 PM

Sorry Mr.Bruce,

 

One more question including this the total of questions will be 4.

 

4, If i give 12 (two digits) also in the cell A1 , the result must be a 5 character + a preding letter D or Q , two are actual and the remaining represents 0 the result must be QDDDCU or DDDDCU.

 

Please reply

Thanks

Anees

1-C,2-U,3-M,4-B,5-E,6-R,7-L,8-A,9-N,0-D

  Anees replied to bruce mcpherson
15-Jul-10 04:12 AM

Dear Mr.Bruce,

 

Can you please help me on the below requests.

 

Thanks for all the help , i have seen your reply for Mr.Ishaq we are not same i recommended him to post the problem.  i have  3 more request on the same topic, and one is other.

1, will i be able to make a D or Q to precede the result (ie) if i give 12345 the result would be Dcumbe

2, on the A1 cell must not accecpt more than 5 character or numerics , it should accecpt 12345 only and the result must be (preceded by a D or Q ) Dcumbe. 

3, If i give 12 (two digits) also in the cell A1 , the result must be a 5 character + a preding letter D or Q , two are actual and the remaining represents 0 the result must be QDDDCU or DDDDCU. 

4, May i know about you - If possible

Please reply and help me

 

Thanks Again

Anees Ahamed

  bruce mcpherson replied to Anees
15-Jul-10 10:17 AM
Hello

can you tell me if you are planning to use the substitute formula, or the array formula, and i will give you the answers tailored to the appropriate one.

What is the big picture of what you are trying to do here?

Bruce
  Mohammed replied to bruce mcpherson
15-Jul-10 11:51 AM

Helo boss,

 

Thanks for the reply, please give me the array formula.sorry for the trouble.infact i need to create some pseudo codes for the fare.which a layman can not understand , i was able to create the formula in five different cells.with your help now i am able to do it in one cell , what ever the code i create it must not exceed 5+1 (preceding D or Q).Hence if i set the cell Say A1  not to allow more than 5 characters obviously the result will not be more than 5 characters, after that i have to add manually the preceding letter D or Q , instead if the answer comes  with the preceding letter Q or D there will not be any manual insertion required .please help me.

 

thanks

 

Anees

 

  bruce mcpherson replied to Mohammed
15-Jul-10 12:14 PM
Hello

Enter this as an array formula. 

=IF(LEN(A1)=2,"QDDDCU","D"&afconcat(CHOOSE(1+MID(A1,( ROW(INDIRECT (1&":"&MIN(5,LEN(A1))))),1),"D","C","U","M","B","E","R","L","A","N")))

If A1 is longer than 5, i ignore the extra characters at the end. 

You did not say how to decide whether the prefix is Q or D. Here i've used Q for when length is 2, and d otherwise. Hopefully you can figure out how to change it as required

Bruce
  bruce mcpherson replied to Mohammed
15-Jul-10 01:25 PM
Hello

Ok I read your questions again, and I think I understand that you are saying that there must be exactly 5 characters, with leading zeroes if necessary - so for example 1520 must first be translated to 01520 before converting it to text. 

If that is the case then this is the array formula you need

="D"&afconcat(CHOOSE(1+MID(LEFT(TEXT(A1,"00000"),5) ,(ROW(INDIRECT(1&":"&5))),1),"D","C","U","M","B","E","R","L","A","N"))

The story about when to use D or Q is not clear though, so i've left it here as a D only.

Bruce
  Mohammed replied to bruce mcpherson
15-Jul-10 01:50 PM

Sir,

 

Its working perfect, sorry i did not specify it properly about the value of Q and D (in our industry) Q stands for commisonable and D as Nett. how ever both the code would precede five characters .and is the below  possible.

 

If i give 2 (two digits) also in the cell A1 , the result must be a 5 character + a preceding letter D or Q , two are actual and the remaining represents 0 the result must be QDDDUD or DDDDUD.   

 

if a value of a product is $20 - i would enter in the cell (A1) as 20 but the result must be DDDDUD (D00020)

 

Please advise

 

Thanks

Anees

  bruce mcpherson replied to Mohammed
15-Jul-10 02:04 PM
Hi

see my subsequent answer - i have dealt with the leading zeroes there. How do you tell if its commissionable or nett? is there some other cell?

Bruce
  Mohammed replied to bruce mcpherson
15-Jul-10 02:25 PM

Sir,

Amazing works perfectly,Thanks again,  i will assaign different cell for Q and D, so it wont be a problem. May i know about you , you have any website ....... to know  or any E-mail id.

 

Thanks

Anees

  bruce mcpherson replied to Mohammed
15-Jul-10 02:42 PM
My biography section has a link to a web site

Good luck

Bruce
Create New Account
help
how do i download a microsoft excel user manual? Excel i'm looking for a user manual that i can download without using the online help function. Excel Miscellaneous Discussions Hithere (1) Jennieo (1) Years (1) hi there are a number of books sure just what your are after but my suggestion is to do a google on excel tutorials or excel tutorials specific subject. i have a library of web sites i have collected over the
excel 2008 for Mac from a lifetime PC Microsoft Excel user convert Windows 7 Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel MAC Office Excel Discussions Microsoft Excel (1) Snow Leopard Processor Intel (1) Decimal (1) Excel Preferences Display (1) Processor (1) Decimal places (1) Cell (1) Excel -> Preferences -> Display this number
microsoft excel has not been installed for current user Excel my microsoft office 2003 is not working any more after update for windows from internet when i try to open excel word or other office application it gives me the microsoft excel is not installed for current user pls run set up for installation although the program
How do I delete a header in Microsoft Excel? Excel I would like to know how to delete a header in Microsoft Excel. Can you help? Excel Miscellaneous Discussions Microsoft Excel (1) Excel 2007 (1) Page (1) Workbook (1) SQRT (1) VBA (1) ShowFormula (1) Anne
reading .sxls files in Office XP 2002 Excel Excel Is there anyway I can allow my 2002 Excel to read .sxls files from the newer versions of Microsoft Excel? Excel Miscellaneous Discussions Office XP (1) Microsoft Excel (1) Office 2007 (1) Excel (1) Bliengme (1) Sxls (1) Caps (1) Docs (1) Hi