Extract information before several special characters in excel - excel

I have a problem with an excel file.
I am trying to extract information from a column. This information appears randomly, before a ".", "-" or ":". So an example would be:
CELL
EXPECTED RESULT
hi.this is:
hi
maybe I- this works
maybe I
Who is: what. like-
Who is
I am using the formula:
=MID(A1,1,FIND("-",A1,1)-1)
Using this one, I get the information I need, but I am not able to add the other characters (".", ":",...) to the formula. Also I have the problem that in a same cell, I can have several of this characters, and I only want the information before the FIRST character (of all posible kinds) that appears in the cell.
I dont know if somebody can help me here.
Thank you very much in advance!

You can try:
Formula in B1:
=TEXTBEFORE(A1:A3,{".","-",":"})
If you don't yet have acces to TEXTBEFORE() then try:
=LEFT(A1,MIN(FIND({".","-",":"},A1&".-:"))-1)
I suppose this is an array-entered formula in versions prior to ms365.

Related

Excel string extraction

My question is, I want to find a specific characters "V-", "C-", or "To", from the value in the cell B2,
The logic is: if either of these characters are found in the cell B2, the excel should take value from D2, and put into new column say E
Here is my if formula:
=IF(MID(B2,FIND("V-",B2),2)="V-",D2,
IF(MID(B2,FIND("C-",B2),2)="C-",D2,
IF(MID(B2,FIND("To",B2),2)="To",D2," ")))
This formula is working for only first occurrence "V-" in this case , the rest of the values it displays "#VALUE!". Can I get any help please.
And return a blank otherwise?
=IF(COUNT(FIND({"V-";"C-";"To"},B2)),D2,"")
Just to spell out what's happening, if it Find fails to find "V-", it immediately returns a #VALUE! error and the formula doesn't proceed any further.
You could fix it like this while preserving your logic
=IF(ISNUMBER(FIND("V-",B2)),D2,
IF(ISNUMBER(FIND("C-",B2)),D2,
IF(ISNUMBER(FIND("To",B2)),D2," ")))
but as you can see from the other answers there are much shorter ways of doing it.
Try this way:
`=IFERROR(FIND("V-",B2),IFERROR(FIND("C-",B2),IFERROR(FIND("To-",B2)," ")))`
returning a positive number when found or " " when no match.
(I could not test it because I use a localised version of Excel but the logic is fine)

COUNTIF formula counts values that don't match

I'm using counting invoice numbers (text) in a table's column, but the Excel formula seems to be confusing some values.
I copied small sample of these - please refer to below:
The formulas are as follow:
=COUNTIFS(A1:A19,A1)
=COUNTIF(A1:A19,A1)
As you can see these invoice numbers differ and the results of these functions suggest as if all were the same.
I googled it for 1 hour but I didn't find such as issue as mine.
If anybody had any clue why could this behave in such way I'll be super grateful!
Rob
Each time you copy down this formula it will add 1 row to each. For example the second row of datas formula will be =COUNTIFS(A2:A20,A2). To lock these cells in the formula use $
Your formula should be =COUNTIFS(A$1:A$19,A1)
I've solved this myself:
ROOTCAUSE
Excel tried to be helpful and read these invoice numbers as actual numbers (despite these being defined already in Power Query as text)
Then, Excel fooled me and despite showing that it works on it as a string (I was evaluating the formula) it worked on it as number
Above means that it transformed exemplary "00100001010000018525" to 1.00001E+17, which cut down this to "100001010000018000" - that's the moment Excel stopped fooling around and showed that value in the formula bar.
I think I don't need to tell why countif perceived all these values as equal.
SOLUTION
I simply appended one letter after each invoice number to get e.g. "00100001010000018525a" what forces Excel to quit its gimmicks and games.
Case closed.
I suspect this is a bug in COUNTIF, or maybe by design.
However, to workaround this in the formula, without having to change your data, try adding a wild-card character:
=COUNTIF(A1:A19,"*"&A1)

Excel Vlookup , too few arguments error

When I try to enter Vlookup formula manually in Excel, I get the following error;
excel manual vlookup error. This error appears while I'm defining the second element of the formula from another excel file and it doesn't let me to define the area.And it directs me to use formula wizard, however it's not useful and efficient for me. Has anyone experienced this problem before?
You may find the formula I try to use as below;
=vlookup(S2;'[Copy of Material Master_S112.xlsx]q_S112'!$G$2:$I$7
after this point it doesn'let me to make any change and directs me to formula wizard.
Thank you for your help in advance
VLOOKUP() takes 4 arguments:
Value to seek.
Target range.
Number of result column relative to the first column of target range. E.g. if your target range is $G:$I and you need results from column H this parameter should be 2, if you want results from column I - then 3.
Parameter specifying whether you need exact (TRUE) or approximate (FALSE) match. Set it to FALSE in most cases.
And of course you need closing parenthesis ) at the end.
So the correct formula should look something like this:
=VLOOKUP(S2;'[Copy of Material Master_S112.xlsx]q_S112'!$G$2:$I$7;3;FALSE)
If you use Ctrl-Shift-Down after you have started to enter the second parameter you will get the "you have entered too few arguments" message.
You can only use Ctrl-Shift-Down after selecting a cell but before you have entered anything for the second VLOOKUP parameter.
As I mentioned in my comment, arguments in Excel formulas are separated by commas, not semicolons.
For example,
=VLOOKUP(S2, '[Copy of Material Master_S112.xlsx]q_S112'!$G$2:$I$7, 2, FALSE)
Thank you for all your answers. It's kind of interesting but, I have to hit at first shift and then control not to get this error. It wasn't like that before but when I hit control first and then shift+down it gives the error. But at least it works like this.
if you use win 10 , you must change the regoin configoration .
in control panel > region >formats> additional setting> list separator
change content to ";"

Sharepoint calculated column returning #Name?

I have a SharePoint calculated column that is as follows:
=RIGHT(Hip,LEN(Hip)-INT(FIND("-",Hip)))
Basically what this does is return the last digits after the "-" in a string, but for strings that do not contain a "-" it returns #Name? into the column. Does anyone know of an easy way to change this formula to make it say what I want? Or is it just easier to re-think the formula all together. Thanks guys.
You need to use an =IF() statement around this if you're using hyphens that may or may not be there. IF(check for hyphen, hyphen formula, non-hyphen formula), The MSDN information is here for the full docs.
Thanks Graham, I appreciate your time. Your thoughts were definitely helpful! Here is the final solution -
=IF(ISNUMBER(FIND("-",Shipprod)),RIGHT(Shipprod,LEN(Shipprod)-INT(FIND("-",Shipprod))),"Not OK")

Removing parts of a cell

In Excel, how do I write a formula that will partially delete a cell (from a certain point onwards).
For example, if A1 is "23432 Vol 23432". I want B1 to just be "23432 " (everything from Vol onwards is removed). Thanks.
you cannot delete cells with formulas in Excel.
you can modify the content of a cell by using formulas. you may use LEFT(), RIGHT(), MID() and other similar string processing functions.
is there any rule about the number? If for example the number is always 5 digits long, you can return "23432" out of "23432 Vol 23432" by typing =LEFT(A1;5)
you might also want to look for the space. think the english equivalent for the german FINDEN-function is FIND(keyword;text;[first charindex]). if splitting by space, you find the number by =LEFT(A1;FIND(" ";A1))
please post detailed information about your problem if you need further assistance.
EDIT: you may also use VBA if your problem needs a custom formula or custom actions taken out on a cell.
EDIT2, SOLUTION:
=LEFT(A1;FIND(" Vol";A1))
is the solution to your problem, iff "Vol" and the rest needs to be removed in any case without condition. Remember that if you have any condition attached to this, you might nest this expression (without the '=' though) in a "IF()"-formula.
hope that helped you.
best regards

Resources