How to get string after first space in Excel - excel-formula

I have MS Excel file with 8k products code. For example:
SOR 309704 or
LEW 2992 6005BK
I need a formula which cut this string to first space.
SOR 309704 to 309704
LEW 2992 6005BK to 2992 6005BK
Can You help me with this problem ?
Kind regards

=FIND(" ",A1) will give you the position of the first space character. Then you can take everything on the right-hand side using the right() function:
=RIGHT(A1, LEN(A1) - FIND(" ", A1))

Related

Trim, Mid, substitute, len for the word following the space after a ~ character

I have various strings with varying length and word placement. The pattern is however, every time a word is found with "~" in front of it, I need to pull the word after the space following it. I've researched quite a bit on mid, left, right, etc functions, but have still not been able to come up with the result I need.
Here are 2 examples of strings:
TRANSACTION FEE: SOLD -1 1/1/2/2 ~IRON_CONDOR MA 100 18 MAR 22 385/390/305/300 CALL/PUT #2.37
TRANSACTION FEE: BOT +1 ~VERTICAL
ANTM 100 (Weeklys) 4 MAR 22 480/485 CALL #.63
For number 1, "MA" should be the result. For number 2, "ANTM" should be the result.
Below are two formulas that seem to get me close to what I'm looking for, but I'm unable to connect the finished result because I just don't understand enough about them. My trials often result in errors haha erg.
=MID(A2,FIND("~",A2)+1,FIND(" ",A2,FIND(" ",A2)+1)-FIND(" ",A2)) '//This doesn't work because it returns "Iron_" for number 1 and "Verti" for number 2
=TRIM(MID(SUBSTITUTE(TRIM($A2)," ",REPT(" ",LEN($A2))), (7-1)*LEN($A2)+1, LEN($A2))) '//This doesn't work because the word needed isn't always the 7th word.
=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)),MAX(1,FIND("~",SUBSTITUTE(A2," ",REPT(" ",99)))-50),99)) '//This returns the word that starts with the "~", but I need the word following it
I'm looking for an efficient formula that will 1st search for the word position that starts with the tilde "~" and then return the word following the space after that.
Anyone familiar with this that could offer a working solution?
In B2, formula copied down :
=TRIM(MID(SUBSTITUTE(MID(A2,FIND("~",A2),99)," ",REPT(" ",99)),99,99))
And,
Your 3rd formula could be modified to this in obtain the target result :
=TRIM(MID(SUBSTITUTE($A2," ",REPT(" ",99)),MAX(1,FIND("~",SUBSTITUTE($A2," ",REPT(" ",99)))+99),99))
Try this:
=LEFT(MID(RIGHT(A1,LEN(A1)-FIND("~",A1)),FIND(" ",RIGHT(A1,LEN(A1)-FIND("~",A1)+1)),LEN(A1)),FIND(" ",MID(RIGHT(A1,LEN(A1)-FIND("~",A1)),FIND(" ",RIGHT(A1,LEN(A1)-FIND("~",A1)+1)),LEN(A1))))

Separate second number from text using Excel formula

I have project number in cell I132. Values are like (just an example what they can be):
654321 - 9000 Workshop
654321 - 2100 Subcontractor
654321 - 3500 Unrealistic
654321 - 6400 Flawless victory
I have only one value in I132 (for example) 654321 - 9000 Workshop. How to separate second number after - (9000) using Excel formula?
I have tried with no success:
=IF(ISERROR(FIND(" ";I132;FIND(" ";I132;1)+1));I132;LEFT(I132;FIND(" ";I132;FIND(" ";I132;1)+1)))
If all your data has this same format as your posted examples (6 digit number followed by space dash space), then use:
=MID(A1,10,4)
EDIT:
If the first number is not always 6 characters long, use:
=MID(A1,FIND(" - ",A1)+3,4)
To make it very generic, we can use the following version:
=LEFT(MID(A1,FIND("-",A1)+2,1000),FIND(" ",MID(A1,FIND("-",A1)+2,1000))-1)
This way it will work even if the first and second numbers have more than 6 and 4 digits. This is basing on the assumption that it will have a dash between the numbers and after the second number is a blank space.
If then format is always the same, with 4 digits numbers, formula should be:
=MID(I132, FIND("-", I132) + 2, 4)
Suppose your data has the same structure across board which is
random number + (space)-(space) + random number + (space) + word
You can use the following formula to find the second number:
=FILTERXML("<t><s>" & SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s[text()='-']/following-sibling::*[1]")
For the logic behind this formula you may give a read to this article: Extract Words with FILTERXML.
Cheers :)

Excel formula: Left & function Right

Good day all,
I'm trying to chop off 9 characters starting from the right in a cell,
when I use the "RIGHT FUNCTION" excel returns the 9 characters chopped off from the right. But I want excel to chop off 9 characters from the right and return the remaining characters to the left. However, I can't achieve this with the "LEFT FUNCTION" because the number of characters to the left varies. Please i need the exact function to chop off 9 characters from the right and the remaining characters to the left will be returned to Cell E5
Example below:
Cell E3 = "HP Deskjet 1510 series (Copy 1) on Ne14:"
I need to chop off " on Ne14:" and return "HP Deskjet 1510
series (Copy 1)" to Cell E5.
Thanks In Advance.
Try this:
=IFERROR(LEFT(E3,LEN(E3)-9),"")
I've done some network and server administration so I'm not sure whether snipping off the last 9 characters would be universally sufficient for a truncation rule. In my experience, networked printer locations could vary in length but the <space>on<space> portion of the full location descriptor would not.
=TRIM(LEFT(E3, IFERROR(FIND(" on ", E3), LEN(E3))))

Extracting first two words from excel before colon

I want to extract the first two words in the following cell C2 before the colon
John Smith: Not attending today
=TRIM(LEFT(C2, FIND("~",SUBSTITUTE(C2, " ", "~ ",2)&"~")))
I tried the above formula but it gives me "John Smith:" it gives me the colon as well
How can I just get John Smith
How about:
=LEFT(C2,FIND(":",C2)-1)
As you probably know, the FIND will tell you what position the colon is at. From there, it seems like a good place to use the "LEFT" function to count X number of characters before that position (the -1 is what makes it stop at the character before the colon)
Note that this only looks for the first colon, and also that if there's no colon, you'll get a "#VALUE" error, so if that's a possibility you're concerned about, you would need to handle it.
Alternate,
=REPLACE(C2, FIND(":", C2), LEN(C2), "")
' or the reverse as,
=REPLACE(C2, 1, FIND(":", C2)+1, "")

Substring in excel

I have a set of data that shown below on excel.
R/V(208,0,32) YR/V(255,156,0) Y/V(255,217,0)
R/S(184,28,16) YR/S(216,128,0) Y/S(209,171,0)
R/B(255,88,80) YR/B(255,168,40) Y/B(255,216,40)
And I want to separate the data in each cell look like this.
R/V 208 0 32
R/S 184 28 16
R/B 255 88 80
what is the function in excel that I can use for this case.
Thank you in advance.
kennytm doesn't provide an example so here's how you do substrings:
=MID(text, start_num, char_num)
Let's say cell A1 is Hello.
=MID(A1, 2, 3)
Would return
ell
Because it says to start at character 2, e, and to return 3 characters.
In Excel, the substring function is called MID function, and indexOf is called FIND for case-sensitive location and SEARCH function for non-case-sensitive location. For the first portion of your text parsing the LEFT function may also be useful.
See all the text functions here: Text Functions (reference).
Full worksheet function reference lists available at:
    Excel functions (by category)
    Excel functions (alphabetical)
Another way you can do this is by using the substitute function. Substitute "(", ")" and "," with spaces.
e.g.
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1, "(", " "), ")", " "), ",", " ")
I believe we can start from basic to achieve desired result.
For example, I had a situation to extract data after "/". The given excel field had a value of 2rko6xyda14gdl7/VEERABABU%20MATCHA%20IN131621.jpg . I simply wanted to extract the text from "I5" cell after slash symbol. So firstly I want to find where "/" symbol is (FIND("/",I5). This gives me the position of "/". Then I should know the length of text, which i can get by LEN(I5).so total length minus the position of "/" . which is LEN(I5)-(FIND("/",I5)) . This will first find the "/" position and then get me the total text that needs to be extracted.
The RIGHT function is RIGHT(I5,12) will simply extract all the values of last 12 digits starting from right most character. So I will replace the above function "LEN(I5)-(FIND("/",I5))" for 12 number in the RIGHT function to get me dynamically the number of characters I need to extract in any given cell and my solution is presented as given below
The approach was
=RIGHT(I5,LEN(I5)-(FIND("/",I5))) will give me out as VEERABABU%20MATCHA%20IN131621.jpg . I think I am clear.
Update on 11/30/2022
With new excel functions, you can use the following in cell C1 for the input in A1:
=TEXTJOIN(" ",,TEXTSPLIT(A1,{"(",",",")"}))
Here is the output:
What about using Replace all?
Just replace All on bracket to space.
And comma to space. And I think you can achieve it.

Resources