Split between deliminator in excel formula - excel

I am attempting to split a percentage using excel formulas. I am trying to get the first portion of the percent before the "-" and the second portion of the percent after the "-".
L16 = 1-7% will cause this to work perfect fine.
L16 = 19-100% will cause the formula to break. I cannot seem to figure out how to get the second portion to work.
I have created 2 formulas.
Grabs first half:
=LEFT(L16,SEARCH("-",L16,1)-1)
Grabs second half(the one not working):
=LEFT(RIGHT(L16,SEARCH("-",L16,1)+0),LEN(RIGHT(L16,SEARCH("-",L16,1)+0))-1)

You can use SUBSTITUTE() for a quick solution:
For the left part:
=LEFT(E2,SEARCH("-",E2)-1)
and the right:
=SUBSTITUTE(RIGHT(E2,LEN(E2)-SEARCH("-",E2)),"%","")

=SUBSTITUTE(RIGHT(L16,LEN(L16)-SEARCH("-",L16)),"%","")

Use this one formula for both:
=--TRIM(MID(SUBSTITUTE(SUBSTITUTE($L16,"%",""),"-",REPT(" ",999)),(COLUMN(A1)-1)*999+1,999))
Put that in the first cell and copy over one and down the data set
And if you want them as percentages then use this:
=--(TRIM(MID(SUBSTITUTE(SUBSTITUTE($L16,"%",""),"-",REPT(" ",999)),(COLUMN(A1)-1)*999+1,999)) & "%")
And format the cells as percentages.

When I copied your formula it worked for me, but then I realized that I put a space on either side of the hyphen. So there is something about the spaces that makes it work, in case that helps you troubleshoot how to fix your formula (I'd leave this as a comment if I had enough rep, sorry).

Related

Extract information before several special characters in 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.

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)

Copy and show what is after last slash from a cell

I have columns with words and / between them.
Like this: I/Want/This
Now i want to make a formula that finds the last / and copies or shows only what is behind the last /. In this case i want "I/Want/This" to only show "This" in a cell.
I know this is possible but could not make it work.
Can you guys help me.
Use following formula:
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",LEN(A1))),LEN(A1)))
See image for reference

Removing hyphens from a cell in Excel

I am looking to take the hyphen or dash out of a birthdate.
01/01/01
01-01-01
I need to combine the birthdate with other fields and it can't have the seperator in it.
I am sure there is a better way. I can get the month and year out, using left & right however I can't figure out how to get the middle out. Below is what I have so far and I know that I can combine them using "&"...if someone can help me with the middle or give me a better equation I would appreciate it.
LEFT(A1,2)
RIGHT(A1,2)
Solution:
=LEFT(F2,2)&MID(F2,4,2)&RIGHT(F2,4)
if it is a string, (not formated as a date) then you can use
MID(A1,4,2)
otherwise i just use the MONTH(A1) DAY(A1) YEAR(A1) functions
I'm not sure what an excel formula is so this answer might be irrelevant...
VBA has a Mid function that would do what you want I believe. This page has good explanations for that and the other similar functions: http://www.vbtutor.net/VBA/vba9.htm
You could also do a Find and Replace to replace the "-" with nothing.
Ctrl + H will bring up the Replace dialog box.
Change the number format of the date to something line "mmddyy". To combine it with other text in another cell, use a formula like:
="The date is "&TEXT(A1,"mmddyy")
where the date is in cell A1.

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