# Excel formating cell/ formula help

Hi guys,

I'm a bit confused about how to format a cell of which formula to use to have the expected end result.

I have a few cells like this:

6491
7620
6486
7610-8
0888-8
0880-9
0888-8
894
890
898

and i would like add a fixed number in between which is 984100, so it would look like this:

64919841000
76209841000
64869841000
76109841008
08889841008
08809841009
08889841008
08949841000
08909841000
08989841000

So those cell that has only 4 digits will have a extra 0 in the end, and those that has a number 1 to 9 in the end will get the last number in the end and those that only have 3 digits will add a extra 0 in the beginning and a extra 0 in the end.

so like this:

6491 = 6491 + 984100 + 0  = 64919841000
and
7610-8 = 7610 + 984100 + 8 = 76109841000
and
894 = 0894 + 984100 + 0 = 08949841000

LVL 1
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
=IFERROR(LEFT(A1,FIND("-",A1)-1) & "984100" & RIGHT(A1,1),IF(LEN(A1)=3,"0","") & A1 & "9841000")
Commented:
Could you ever have only 3 digits to the left of the hyphen? (e.g. 888-8 rather than 0888-8)
Author Commented:
Awesome!
This works although there is one thing, those that only has 3 digits in the cell it need to add a 0 in the start aswell... how to do so?
Author Commented:
Rory, yes that is possible that it may happen
Commented:
I should note that the IFERROR() function only works on Excel 2007 onwards. Example workbook attached. If you need this to work in older versions, it can be rewritten to use backward compatible functions.
EE.xlsx
Commented:
Taking note of the 3 digit value followed by hyphen:

=IFERROR(IF(LEN( LEFT(A2,FIND("-",A2)-1))=3,"0","") & LEFT(A2,FIND("-",A2)-1) & "984100" & RIGHT(A2,1),IF(LEN(A2)=3,"0","") & A2 & "9841000")
EE.xlsx

Experts Exchange Solution brought to you by