Solved

Excel formating cell/ formula help

Posted on 2014-11-19
7
106 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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 …
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

832 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