Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need one column to show the following text: prxyz,(data1 here),0699,ABCD(data2 here),xxx

data1 is in column A and data2 is in column B.

the format of data1 needs to be 5 numbers (sometimes beginning with zeros). for data2, they need to type in data that's 9digits long and ends in a letter. if they enter 9 digits only, the letter needs to automatically be substituted with 0 (zero).

so for example i enter '123' in A1, '12345' in A2, '123456789' in B1 and '987654321Z' in B2, it needs to come out as:

 |   A   |      B        |          C
1| 00123 |  123456789    |  prxyz,00123,0699,ABCD1234567890,xxx
2| 12345 |  987654321Z   |  prxyz,12345,0699,ABCD987654321Z,xxx

I've formatted col A out w custom format 00000 for it to always display 5digits. But I'm stuck on Column B and C.

This is what I've come up with but it's not correct: ="prxyz,"&A1&",0699,"&"ABCD"&B1&",xxx"

Please help? Ideas?

share|improve this question

migrated from stackoverflow.com Nov 2 '10 at 11:37

This question came from our site for professional and enthusiast programmers.

4 Answers 4

 ="prxyz,"&TEXT(A1,"00000")&",0699,ABCD"&IF(LEN(B1)=9,B1*10,B1)&",xxx"
share|improve this answer
    
i learned that ="prxyz,"& TEXT(A1,"00000")&",0699,"& "ABCD"& LEFT(B1,9)&IF(ISNUMBER( VALUE(RIGHT(B1,1))),"0,xxx",( RIGHT(B1,1)&",xxx")) works too but yours is a lot simpler. :) I think the last bit with the LEN and b1*10's pretty clever too. Thanks a lot, Joel! –  excel gamine Feb 7 '09 at 6:32
    
thanks for the acceptance! –  Joel Spolsky Feb 7 '09 at 6:36

To do your leading zeroes, you could use the TEXT formula:

="rxyz,"&TEXT(A1,"00000")& ...

I'd have to think about your column B.

share|improve this answer
    
very cool! Thanks, Ray! I hope you can help me out with Column B too wink –  excel gamine Feb 7 '09 at 5:15

There is a way to use a syntax similar to ="prxyz,"&A1&",0699,"&"ABCD"&B1&",xxx" but I would recommend against it. Instead create a data mask somewhere like this (same sheet or another):

 |F     |G|     H    |I|  J  
1|Data Mask:         | |  			
2|prxyz,|A|,0699,ABCD|B|,xxx

Once you have the data mask set up use a formula like this:

=$F$2&A1&$H$2&B1&$J$2

Where the $F$2 and so forth are you mask cells and the A1 and B1 are you entered data. That way when you expand the table it will compute automatically.

It appears as though someone beat me to the data validation part. If your still having trouble I can upload a spreadsheet.

EDIT: For column B; If the letter is always the same, it may be better to remove any letters from the number and add them to the next data mask entry. Even if they are different, it may be easier to remove it, and then add it back to ensure you don't miss any.

share|improve this answer
    
Hi, Phil! For Column B, the suffix or letters on the end would be different too.. I don't think I've heard of data mask before. I looked it up in Google and it seems likes it's VBA and I'm not very skilled at it yet. If you could upload a spreadsheet, I'd really appreciate it! –  excel gamine Feb 7 '09 at 5:18
    
Here is an example: philcyr.com/content/ExampleStringFormulation.xls Sorry for the confusion, I don't think that I properly applied the term. I also do not have a solution for the data validation yet. –  Phil Feb 7 '09 at 5:46

hi try this one =CONCATENATE("prxyz,", A1,",","0699",",","ABCD",B2,"xxx");

enter values in A,B column and and then enter the above formula in C column;

next drag the black solid square at bottom-right of selected formula cell downwards

you will get all concatenate cells of A and B with your text and number values.

to get values separately copy the concatenated cells and paste-special in another sheet

select "value" click ok.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.