I want to extract string before "_" or "." characters.
e.g..
My C column can have following values and expected output in E:
C E
115415.csv 115415
12345_BOI_CEO.csv 12345
I have a formula for "_" i.e.
IFERROR(LEFT(C10, FIND("_", C10)-1),"")
So I want a formula which would extract string before the character mentioned in a single formula and not separate formula.
It seems you were on the right track. Put one of the following standard formulas in E2,
=REPLACE(C2, MIN(FIND(".", C2&"."), FIND("_", C2&"_")), LEN(C2), TEXT(,))
=LEFT(C2, MIN(FIND(".", C2&"."), FIND("_", C2&"_"))-1)
Standard formula in F2 as,
=MID(C2, IFERROR(FIND("_", C2)+1, 1), FIND(".", C2)-IFERROR(FIND("_", C2)+1, 1))
Fill down as necessary.
Another way
=MID(C2,1,MIN(SEARCH(".",C2&"."),SEARCH("_",C2&"_"))-1)
If you intend to do this once, we could use the Text to Columns menu option twice.
First split by _(underscore), then again by .(dot). See below for the first step.
Related
One of my excel columns like below.
COL A COL B
----------------------------------------
ABCDEFGH ABCDEFGH-#648-2011 EXT.8503
In column C , I wanted value should be -#648-2011 EXT.8503
How can I do this in Excel?
I have tried formula like this :
=LEFT(B242,LEN(LEFT(A242,LEN(A242))))
However, its not working, please suggest?
Looking at your data it seems that B2 has a value with A2 sticked to the left of it. If this is the case then you could use:
=RIGHT(B2,LEN(B2)-LEN(A2))
If this isn't the case and it is just a coincidence, then I agree with #Tim Biegeleisen his answer :)
EDIT:
Might you want to exclude the hyphen then use:
=RIGHT(B2,LEN(B2)-LEN(A2)-1)
Many solutions:
You could replace the first instance of A1- in B1 with a null string:
=SUBSTITUTE(B1,A1&"-","",1)
or start after a certain location:
=MID(B1,LEN(A1)+2,99)
If you really want to include the hyphen in the result in column C, then make the minor changes in the formulas above
=SUBSTITUTE(B1,A1,"",1)
=MID(B1,LEN(A1)+1,99)
Try using this formula:
=MID(B1, FIND("-", B1), LEN(B1) - FIND("-", B1) + 1)
This says to take a substring, starting at the position of the first dash -, for the remainder of the string after that starting point.
What I am trying to do is concatenate two cells, then check that concatenated value against a column of values, and put an X in a cell if such a value exists. The following equation is what I'm using:
{=IF(CONCATENATE(A2, " ", B2) = 'MasterList'!$C:$C, "x", "")}
Column A is the name of the software and Column B the version number (A="Microsoft .NET Framework 4.5.1", B="4.5.50938", for example). I know that this concatenated value exists on the MasterList worksheet so I don't understand why I'm not getting the answer I expect.
Gurus, what's my flaw here?
The fastest comparison/lookup on the worksheet is a MATCH function. If you have a long column to put this formula into you could try,
=IF(ISNUMBER(MATCH(CONCATENATE(A2, " ", B2), 'MasterList'!$C:$C, 0)), "x", "")
Fill down as necessary.
It seams that you select the entire column C on yout MasterListSheet. Don't you mean just one cell? Like:
=IF(CONCATENATE(A2, " ", B2) = 'MasterList'!$C1, "x", "")
or try to : =IF(CONCATENATE(A2, " ", B2) = MasterList.!$C1, "x", "") (on open Office)
Best thing is instead of you write the Sheet name, let Excel do it for you by editing the formula, remove the sheet name and then with a mouse click navigate to the desired area.
I just want to say that before seeing this question, I had no idea what array formulas were.
I have the following working example:
Sheet1:
A1: Microsoft .NET Framework 4.5.1
B1: 4.5.50938
// press control-shift-enter after typing formula
C4: =IF(CONCATENATE(A1," ",B1)=Sheet2!$A:$A,"YAY","NAY")
Sheet2:
A1: Microsoft .NET Framework 4.5.1 4.5.50938
Not sure what the issue is with your spreadsheet. Do the values in MasterList!$C:$C actually correspond to what you expect as the result of the concatenation?
This is not a valid array formula. The LHS is a single cell while the RHS is an array. What it actually does is compare the concatenation to all cells of columns C in MasterList.
You either need to make it a valid array formula or a normal formula. I recommend the second solution.
For the first solution, it should be:
{=IF(CONCATENATE(A:A, " ",B:B ) ='MasterList'!$C:$C, "x", "")}
However, this will be very slow because it will compute and concatenate two full columns, and moreover you will have to select your whole range where you want to calculate it (a full columns) then press Ctrl+Shift+Enter.
You can make it a simple formula in on cell then copy/paste along your column. Formula for C2:
=IF(CONCATENATE(A2, " ", B2) = 'MasterList'!$C2, "x", "")
In excel, TRIM() will remove all spaces before and after text, while also removing any duplicate spaces in between words.
Is there a formula or combination thereof that will do the same as TRIM() but leave spaces between words as-is?
In the following example, I'm looking for a formula that will accomplish that of the fictitious formula "WXYZ":
TRIM(" Omicron Persei 8 ") = "Omicron Persei 8"
WXYZ(" Omicron Persei 8 ") = "Omicron Persei 8"
Note that I've read somewhere that TRIM() in VBA will work like that of WXYZ above. However, I'm looking for a formula solution.
I believe this should work (assuming your string is located at A1):
=MID(A1,
FIND(LEFT(TRIM(A1),1),A1),
(LEN(A1)-MATCH(RIGHT(TRIM(A1),1),INDEX(MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1),0),0)-FIND(LEFT(TRIM(A1),1),A1)+2)
FIND(LEFT(TRIM(A1),1),A1) returns the location of the first non-space character in the string
MATCH(RIGHT(TRIM(A1),1),INDEX(MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1),0),0) returns the location of the last non-space character in the string from right-to-left.
How would this look in Excel 365? A bit easier I think with let, sequence and xmatch but not particularly short:
=IFERROR(LET(seq,SEQUENCE(LEN(A2)),
array,MID(A2,seq,1),
start,XMATCH(TRUE,array<>" "),
finish,XMATCH(TRUE,array<>" ",0,-1),
MID(A2,start,finish-start+1)),"")
Just to add to all the valuable content:
Formula in B1:
=LET(x,TEXTSPLIT(A2," ",,1),TEXTJOIN(DROP(DROP(TEXTSPLIT(" "&A2&" ",x),,1),,-1),,x))
A Formula Array could also be used.
Assuming the string is located at A1 enter this Formula Array in B2. It's highly suggested to ensure this part of the formula ROW(B:B) refers always to the same column were the formula is located (column B in this case), this is in order to avoid the formula returning an error if the column to which it refers is deleted.
=MID($A1,
FIND(LEFT(TRIM($A1),1),$A1),
1+MAX(ROW(B:B)*(ROW(B:B)<=LEN($A1))*(MID($A1,ROW(B:B),1)<>" "))
-FIND(LEFT(TRIM($A1),1),$A1))
FormulaArrays are entered pressing [Ctrl] + [Shift] + [Enter] simultaneously, you shall see { and } around the formula if entered correctly
As regards the formula provided by #Aakash I suggest to replace the INDIRECT function in this part:
-ROW(INDIRECT("1:"&LEN($A7)))
with this:
-ROW(B:B)
So the formula will become Non-Volatile:
=MID($A1,
FIND(LEFT(TRIM($A1),1),$A1),
(LEN($A1)-MATCH(RIGHT(TRIM($A1),1),INDEX(MID($A1,LEN($A1)-ROW(B:B)+1,1),0),0)
-FIND(LEFT(TRIM($A1),1),$A1)+2))
I am new to excel, I have a data of 1000 rows with each row looks like 435362|A|B|C I want a formula in excel which modifies each rows so that the data looks like 435362,A|B|C i.e. it should replace first occurrence of | with comma(,).
One more option: (with data in A1):
=SUBSTITUTE(A1,"|",",",1)
You can't replace existing data with forrmula, so you need to create another column. You can then cut and paste as values to replace existing data.
With data in A1, in B1 enter:
=MID(A1,1,FIND("|",A1)-1) & "," & MID(A1,FIND("|",A1)+1,9999)
and copy down
If every string in all 1000 rows is the same length, this should do the trick:
=REPLACE(A1,LEN(A1)-5,1,",")
Explanations:
The two instances of "A1" in the formula are the cell references, these would need to change for each cell in order to work, but if you copy the formula across cells this value should change automatically.
The LEN is finding the length of the string in the cell, then the -5 is finding the symbol 5th from the end (in this case the "|"). The 1 is saying only replace this one symbol (2 would replace "|" and "A"), and the "," is telling the formula which symbol to replace the "|" with".
I hope this works for you!
If your data have the same char length the you can use =CONCATENATE(LEFT(B3,6),",",RIGHT(B3,5)) B3 is where your data is located in this case.
This is only one way of doing it.
Can you tell me if I want to find the last character in Excel based on condition
let say last character if it is A then replace it with X, or if it is b then replace it with Z.
I want to do it with formula
If your value is in A1 cell, then try applying the following formula in B1 cell.
Formula
=IF(RIGHT(A1,1)="a", LEFT(A1,LEN(A1)-1) &"x", IF(RIGHT(A1,1)="b",LEFT(A1,LEN(A1)-1) & "z",A1))
If you are looking for last character to be exactly A, then try the following formula.
Formula
=IF(EXACT(RIGHT(A1,1),"A"), LEFT(A1,LEN(A1)-1) &"X", IF(EXACT(RIGHT(A1,1),"B"),LEFT(A1,LEN(A1)-1) & "Z",A1))
You can use this formula. See the example sheet to understand the values.
In Example:
"A2": Original Text
"B2": Result
=IF(RIGHT(A2,1)="A",REPLACE(A2,LEN(A2),1,"X"),IF(RIGHT(A2,1)="B",REPLACE(A2,LEN(A2),1,"Z"),A2))