Solved

Excel formating cell/ formula help

Posted on 2014-11-19
7
107 Views
Last Modified: 2014-11-19
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


Hope this made sense
0
Comment
Question by:Hakum
  • 3
  • 3
7 Comments
 
LVL 18

Expert Comment

by:Simon
ID: 40451848
=IFERROR(LEFT(A1,FIND("-",A1)-1) & "984100" & RIGHT(A1,1),IF(LEN(A1)=3,"0","") & A1 & "9841000")
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 40451852
Could you ever have only 3 digits to the left of the hyphen? (e.g. 888-8 rather than 0888-8)
0
 
LVL 1

Author Comment

by:Hakum
ID: 40451853
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?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:Hakum
ID: 40451854
Rory, yes that is possible that it may happen
0
 
LVL 18

Expert Comment

by:Simon
ID: 40451856
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
0
 
LVL 18

Accepted Solution

by:
Simon earned 500 total points
ID: 40451861
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
0
 
LVL 1

Author Comment

by:Hakum
ID: 40451866
Thanks alot SimonAdept! works like a charm!

Thanks alot for quick help!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question