How to change string name to specific string name? - excel

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)

Related

create hyperlink using cell value and some additional text in excel

I have excel sheet containing column with values such as
BANDHANBNK
SRF
SRTRANSFIN
L&TFH
IBULHSGFIN
FEDERALBNK
PNB
PEL
VOLTAS
I want to create hyperlink for each of this, url can be created as
https://in.tradingview.com/chart/?symbol=NSE:ACC1!
so I need to concatenate
https://in.tradingview.com/chart/?symbol=NSE: + cell value + 1!
doing this manually is too much work, is there any simpler way to do this?
one more thing is if cell value contains & or - it should be converted to underscore.
Use following formula. Here simply concatenating cell value with URL then concatenate 1!. Use Hyperlink() formula to make hyperlink.
=HYPERLINK("https://in.tradingview.com/chart/?symbol=NSE:" & A1 & "1!",A1)
To replace & and - by underscore _ use below SUBSTITUTE() formula.
=SUBSTITUTE(SUBSTITUTE(A1,"&","_"),"-","_")
this worked for me.
=HYPERLINK("https://in.tradingview.com/chart/?symbol=NSE:" & SUBSTITUTE(SUBSTITUTE(E2,"&","_"),"-","_") & "1!",E2)

Separating Data in Excel with formuals

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.

How to extract middle characters from a cell in Excel

I need a excel function code that would enable to me extract certain characters in the middle of a cell.
So in cell A74 is:
1625362674848-cdpresent-auths_ol_mart-auths1837372
So I Need to extract "auths_ol_mart" into a separate column
I have tried this:
=MID(A2, SEARCH("-",A2) + 1, SEARCH("-",A2,SEARCH("-",A2)+1) - SEARCH("-",A2) - 1)
Now the problem is this only gets "cdpresent". I am not quite sure how this is done.
more examples include:
3837463747-cdpresent-avaya_op_history-clm1827489
I want "avaya_op_history"
3734279458-cdpresent-uk_score_app-clm9377233
I want "uk_score_app"
Thank you all
You can use this worksheet formula:
=LEFT(MID(A1,FIND("-",A1,FIND("-",A1)+1)+1,99),FIND("-",MID(A1,FIND("-",A1,FIND("-",A1)+1)+1,99))-1)
If you use the Formula Evaluation tool, you will be able to see how this works.
If you prefer a UDF, you can use:
Function betweenDashes(S As String) As String
betweenDashes = Split(S, "-")(2)
End Function
Edit (20MAR2020)
Another formula to return the third item in the string, if you have Excel 2013+ and the FILTERXML function:
=FILTERXML("<t><s>" & SUBSTITUTE(A1,"-","</s><s>")& "</s></t>","//s[3]")
or, if you prefer, the next to last item:
=FILTERXML("<t><s>" & SUBSTITUTE(A1,"-","</s><s>")& "</s></t>","//s[last()-1]")
An alternative way to formula is Text to Columns with hyphen (-) as a delimiter. You get what you are looking for in the 3rd column:

How to add a simple quote into a text string?

I have a name list like
Horak
Marek
Tihoun
etc...
and I want
'Horak'
'Marek'
'Tihoun'
I'm quite new to Excel, is there a way how to do that?
Thanks in advance.
Assuming that your data is in column A, isn't this as straight-forward as something like:
="'" & A1 & "'"
This will concatenate the quote ' with the data in A1 with another quote '.
If Horak was in cell A1 put the following in cell B1 and drag down for as many rows as you have entries in column A.
="'"&A1&"'"
You could also use
=CONCATENATE("'",B2,"'")
Example usage shown:
That can be done through the following ways...
When you want to add the ' to text by &
="'"&"Horak"&"'"
When you want to add the ' to column by &
="'" & [ColumnIndex] & "'"
When you want to add the ' to column by CONCATENATE()
=CONCATENATE("'",[ColumnIndex],"'")

Excel formula to remove space between words in a cell

I've a huge data in excel file.
For eg: say i've a word like paul son,i've to make it as paulson.
input:paul son
output:paulson.
In some cells ,i've data like mic-li,when this type of words come,it should not replace any thing,it should only remove spaces in between words.
Suppose the data is in the B column, write in the C column the formula:
=SUBSTITUTE(B1," ","")
Copy&Paste the formula in the whole C column.
edit: using commas or semicolons as parameters separator depends on your regional settings (I have to use the semicolons). This is weird I think. Thanks to #tocallaghan and #pablete for pointing this out.
It is SUBSTITUTE(B1," ",""), not REPLACE(xx;xx;xx).
Steps (1) Just Select your range, rows or column or array ,
(2) Press ctrl+H , (3 a) then in the find type a space
(3 b) in the replace do not enter anything,
(4)then just click on replace all.....
you are done.
Just wanted to add on to vulkanino's answer... now 10 years later ha. This is what I was looking for maybe someone else is too. You can also build on multiple =SUBSTITUTE() functions.
Here is what I used to format a list of names for Active Directory accounts. B2 is where the name would go. I wanted to change the space between the First name and last to a period and omit any hyphens from names.
=SUBSTITUTE(SUBSTITUTE(B2, " ", "."), "-", "")
For example the line above would look like this:
First Last-Name => First.LastName
, "-", "")
This part removes the hyphen.
(B2, " ", ".")
This part selects the cell to modify and changes empty space to a period.
=SUBSTITUTE(SUBSTITUTE(...)...)
I used two substitute functions one inside the other.

Resources