Jyggalag

Active Member
Joined
Mar 8, 2021
Messages
445
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi all!

I have this setup (albeit much larger in reality):

1650376366965.png


Every statement has a sentence with "XYZ employees".

Is there a formula that can detect when a sentence says a number, followed by the string value "employees", and then return the value of the number? So that formula can fill out what is currently column C in the picture above.

Would be immensely helpful!

I hope that my request makes sense, otherwise please feel free to ask me questions and I will be happy to elaborate :-)

Kind regards,
Jyggalag
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Can you post some sample data, rather than an image.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
365 solution. There are problems - like the fourth one where the word employee comes up more than once. I left columns E, F, and G in there to see it a bit more clearly.

MrExcelPlayground8.xlsx
BCDEFG
2The company noted that 3 employees left after december 2021325The company noted that 33
3He wanted to fire all 5 employees left in his division, which had a total of 10 people in it.524He wanted to fire all 55
4They decided to setup a team of 10 employees to work on the project.1035They decided to setup a team of 1010
5The employees didn't like the other 10 employees.04The0
6I am very tall.0#VALUE!#VALUE!0
7There is 1 employee in there.111There is 11
Sheet8
Cell Formulas
RangeFormula
E2:E7E2=SEARCH(" employee",B2)
F2:F7F2=LEFT(B2,E2-1)
G2:G7G2=MAX(IFERROR(VALUE(RIGHT(F2,SEQUENCE(LEN(F2)))),0))
C2:C7C2=MAX(IFERROR(VALUE(RIGHT(LEFT(B2,SEARCH(" employee",B2)-1),SEQUENCE(LEN(LEFT(B2,SEARCH(" employee",B2)-1))))),0))
 
Upvote 0
Another option using James's data
+Fluff 1.xlsm
AB
1
2The company noted that 3 employees left after december 20213
3He wanted to fire all 5 employees left in his division, which had a total of 10 people in it.5
4They decided to setup a team of 10 employees to work on the project.10
5The employees didn't like the other 10 employees.10
6I am very tall. 
7There is 1 employee in there.1
Lists
Cell Formulas
RangeFormula
B2:B7B2=IFERROR(FILTERXML("<k><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></k>","//m[contains(.,'employee')]/preceding::m[.=number()]"),"")
 
Upvote 0
Solution
Another option using James's data
+Fluff 1.xlsm
AB
1
2The company noted that 3 employees left after december 20213
3He wanted to fire all 5 employees left in his division, which had a total of 10 people in it.5
4They decided to setup a team of 10 employees to work on the project.10
5The employees didn't like the other 10 employees.10
6I am very tall. 
7There is 1 employee in there.1
Lists
Cell Formulas
RangeFormula
B2:B7B2=IFERROR(FILTERXML("<k><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></k>","//m[contains(.,'employee')]/preceding::m[.=number()]"),"")
Amazing!

Thank you so much Fluff, and James!

Much appreciated! And noted Fluff, will try to upload like James did going forward :-)
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top