Solved

Excel formating cell/ formula help

Posted on 2014-11-19
7
110 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

626 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