Separating Data in Excel with formuals - excel

I have to separate the following screenshot into the corresponding columns at the top.
I was able to figure out column D & F; however, I am having trouble separating the rest of the problem.
Constraint:
I cannot use the Text-To-Column format.
Zip codes must be 5 digits -> the leading 0 gets lost when string are translated to numbers
I need to use formulas along the lines of right/left/mid/find/search/etc.
The Role formula is:
=MID(A2, SEARCH(",",A2) + 1, SEARCH(",",A2,SEARCH(",",A2)+1) - SEARCH(",",A2) - 1)
The City is:
=LEFT(A2,FIND(",",A2)-1)

Equivalent formula of Text-To-Columns would be like below.
=TRIM(MID(SUBSTITUTE(","&$A2,",",REPT(" ",199)),199*1,199))
Depending on your requirement change number 1 in 199*1 by the field number i.e.
first field corresponds to 1
second field corresponds to 2
and so on...
Implement for the first data row and then copy down.
Edit:
If this data was to be sequentially split then following approach could have been easier instead of hard coded number...
=TRIM(MID(SUBSTITUTE(","&$A2,",",REPT(" ",199)),COLUMNS($A$1:A$1)*199,199))
Copy down and across!
** Edit2: **
For finding out first name and last name above formula will need addition of LEFT or RIGHT along with the same SUBSTITUTE & TRIM construct.
First name : =TRIM(LEFT(SUBSTITUTE(TRIM(MID(SUBSTITUTE(","&$A2,",",REPT(" ",199)),3*199,199))," ",REPT(" ",199)),199))
Last Name : =TRIM(RIGHT(SUBSTITUTE(TRIM(MID(SUBSTITUTE(","&$A2,",",REPT(" ",199)),3*199,199))," ",REPT(" ",199)),199))
Assumes you have at least two words separated by one space minimum!

Not simple, but if you have Excel 2013+ with the FILTERXML function, you can use the following formulas:
First Name: =LEFT(FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[3]"),
FIND(" ",FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[3]"))-1)
Last Name: =MID(FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[3]"),
FIND(" ",FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[3]"))+1,99)
Role: =FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[2]")
Branch: =FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[6]")
City: =FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[1]")
State: =FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[4]")
Zip: =TEXT(FILTERXML("<t><s>" & SUBSTITUTE($A1,",","</s><s>") & "</s></t>","//s[5]"),"00000")
Using the commas to define the nodes, we create an XML
We then use the position parameter \\s[postion] to decide which node to extract
We also look for the space to separate the first from the last names.
As written, this will extract the first word as first name, and the second and any subsequent words as the last name.
If you have entries with just a single name word, just modify the $A1 in those two formulas to $A1 & " "
We also used the TEXT function to format the Zip as 5 digits. If you have 5+4, you'll need to make the appropriate change in the format code.

Related

Creating a formula to avoid dragging down without using (=array)

I have three formulas
(1) =(B2:B&"."&substitute(substitute(lower(C2:C),"jalan","jln")," ",""))
(2) =COUNTIF('Payment Configuration'!A:A,A2:A) + COUNTIF('Payment Configuration'!E:E,A2:A)
(3) = =IF(ISBLANK(B:B),,B:B & ", " & UPPER(C:C) & ", BANDAR PUTERI KLANG")
Guys, I want to dragging this formula's until the last row without using Array formula because if I convert this formulas into array somehow it is not working in my web app (which is written in Google App Script). So anyone can help me with this formulas. Thanks in advance
If you want them to only work on a line at a time you need to trim the range to one row only:
=(B2&"."&substitute(substitute(lower(C2),"jalan","jln")," ",""))
=COUNTIF('Payment Configuration'!A:A,A2) + COUNTIF('Payment Configuration'!E:E,A2)
=IF(ISBLANK(B2),,B2 & ", " & UPPER(C2) & ", BANDAR PUTERI KLANG")
With the first two, you could add ISBLANK like your 3rd example.

How to find a specific number in a string of numbers in Excel

I am looking for help with a formula in Excel to find a specific number in a string of numbers.
Our accounting system pulls a report showing numbers from 1 to 10 and each line can have numerous numbers listed in the cell, each separated with a ";".
What I want to do is create a formula that allows me to simply look for the number in columns O to X (row 3) and fill that number in the corresponding cell.
So starting from row 4, I would like to create a formula that finds each number in the string and simply fills in the one I am looking for in each cell, for example I would like the end result to look like the below example:
If the number doesn't appear then that column is left blank, but if it is found it simply adds itself into the corresponding column.
Hopefully someone out there can help me with this.
Regards;
Greg
formula in B3
in German:
=WENN(ISTFEHLER(FINDEN(";" & B$2 & ";"; ";" & $A3 & ";"));"";B$2)
in English:
=IF(ISERROR(FIND(";" & B$2 & ";" , ";" & $A3 & ";")),"",B$2)
Try this in cell O4:
=IF(NOT(ISERROR(SEARCH(O$3,$N4,1))),O$3,"")
Notes:
Assumes your numbers 1 to 10 are in row 3 (i.e O3:X3)

How to create a long row of names out of two lists in Excel

I would like to make a long column of names that are made up of two lists, like so:
List 1: Library, Theater, Cinema, Casino
List 2: CityCentre, CentreEdge, OuterCity, Rural
Turn it into a column:
Library_CityCentre,
Library_CentreEdge,
Library_OuterCity,
Library_Rural,
Theater_CityCentre,
Theater_CentreEdge,
Theater_OuterCity,
etc...
Edit:
Here is a sample picture of the excel:
Excel Sample of the desired result
Try this to have your output in a single column.
=IFERROR(INDEX(List_1,INT((ROWS($1:1)-1)/COUNTA(List_2))+1,1) & "_" & INDEX(List_2,MOD(ROWS($1:1)-1,COUNTA(List_2))+1,1),"")
and fill down as far as needed.
If your lists are set up differently, you can adjust the formula to fit, but the idea is using the INDEX function and a mathematical formula to return the appropriate items from each list (array).
Try the below:
=$B$1 & "_" & A2
=$C$1 & "_" & A2
=$D$1 & "_" & A2
=$E$1 & "_" & A2
Results:

How to change string name to specific string name?

I want Excel (or Linux command) to change the string of values.
From:
e.g. column A
IN_EMAIL.201_101300_180403_131131_6160_5593
To:
e.g. column B
EMAIL.201_101300_0_180403_131131616_0000_5593
So:
Remove "IN_"
Add "0_" after 20th character
Remove "_" after 33rd character
Add "_000" after 37th character
I've got two formulas. How can I nest them into one?
=REPLACE(REPLACE(A4;1;3;"");18;0;"0_")
=REPLACE(REPLACE(B4;33;1;"");36;0;"_000")
It is solved,
=REPLACE(REPLACE(REPLACE(REPLACE(A11;1;3;"");18;0;"0_");33;1;"");36;0;"_000")
If you want to combine these two formulas:
=REPLACE(REPLACE(A4;1;3;"");18;0;"0_")
=REPLACE(REPLACE(B4;33;1;"");36;0;"_000")
Just replace B4 with the first formula
=REPLACE(REPLACE(REPLACE(REPLACE(A4;1;3;"");18;0;"0_");33;1;"");36;0;"_000")
Alternatively you could use the following formula that might be more obvious:
=MID(A5;4;17) & "0_" & MID(A5;21;13) & MID(A5;35;3) & "_000" & RIGHT(A5;6)

Excel spreadsheet - combine rows in column 1 and 2, 3 and 4 and so on

The only way my client can provide me these addresses is with the location is in one row: Location Name, street address, city.....and then the row below it contains the zip code. This repeats for 1600 lines.
I, of course, need all the info on one line. Is there a genius out there than knows how to make short work of putting the zip code on the line above it?
If you have address in columns A, B and C in the first row and zip code in column A in second row, try the below formula,
=INDEX(A:A,ROW()*2-1,1)&" " &INDEX(B:B,ROW()*2-1,1)& " " & INDEX(C:C,ROW()*2-1,1)& " " &INDEX(A:A,ROW()*2,1)
If you are starting from some other row other than row 1, you may have to modify the formula a little bit. Hope this helps.
Use a formula to combine your columns.
Here we have some test data.
In column D, specify a formula such as =A1 & ", " & B1 & " " & C1
If you're no familiar with formulas, just use "=" to denote the start of one, and then use "&" to concatenate your values.
As for as implementing this on a multi-row basis, you can easily do so. Once you drag your formula down, it'll auto increment the column names unless you specifically specified it not to. I won't get into that right now though.
So what I would do is just add an IF statement in your formula to account for those rows which are not intended to be used. Using a formula such as this: =IF(B1="", "", A1 & ", " & B1 & " " & A2), I can get the following results.

Resources