Find a particular word in a STRING of text ?

Dolcevita

New Member
Joined
Mar 23, 2021
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hello


First things first, I am so grateful to have access to a forum where I can ask questions on Excel?. I am a bit of an Excel virgin - I have been around the block many times but only ever got to first base, never really got into the saucy stuff - this is my first proper foray into the subject of functions, so if you could go slow with me I would be grateful!!

i am (trying to) creating an excel function. The cell, let's call it D5, contains a full sentence of words. I want to create a function that detects the word "work", or "job", or "furlough" in that sentence. If it finds any of those words within the sentence I want it to print the word "employment".

THe formula/function i have created only detects the word "work" if it's the only word in the cell.

Here is my wholly inadequate function:cautious::

=IF(K2="work","EMPLOYMENT") - its not doing what i want it to do!!!

My question is - where am I going wrong? Is the IF function the wrong function? Is there a way of Excel finding the word "work" in amongst the other words? If so could you help me construct it?

Thanks for the help guys!

Dolcevita
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi & welcome to MrExcel.
How about
+Fluff 1.xlsm
AB
1
2I am not at work todayemployed
3I don't have a jobemployed
4Is the furlough scheme still running?employed
5I am unemployed 
Data
Cell Formulas
RangeFormula
B2:B5B2=IF(SUM(IFERROR(FIND({"work","job","furlough"},A2),0))>0,"employed","")
 
Upvote 0
Hi,

there are many ways but something like that would work

VBA Code:
Function findEmployment(ByVal strText As String) As String
    If strText Like "*work*" Or strText Like "*job*" Or strText Like "*furlough*" Then
        findEmployment = "employent"
    Else
        findEmployment = strText
    End If
End Function

now you just could use the function within your vba code
HTH
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Hi,

there are many ways but something like that would work

VBA Code:
Function findEmployment(ByVal strText As String) As String
    If strText Like "*work*" Or strText Like "*job*" Or strText Like "*furlough*" Then
        findEmployment = "employent"
    Else
        findEmployment = strText
    End If
End Function

now you just could use the function within your vba code
HTH
Hi SIlent wolf - thanks for this -but can I use thisprogram in Excel 2019 version? I have never seen an Excel function written like that before. Seems like programming language - would it work?
 
Upvote 0
Hi,
This works in Excel 2019 in VBA..
But if you are not familiar with VBA then Fluffs answer ist working ;)

Once you like to learn VBA you might find little UDF's User defined functions quite useful.

HTH
 
Upvote 0
Hi,

I'm thinking we should "Isolate" your key words in the text string, (e.g. the word "work" is inside "working", and "job" inside "jobless", etc.):

Book3.xlsx
AB
1I am not at work todayEmployment
2I'm currently jobless 
3I don't have a jobEmployment
4Is the furlough scheme still running?Employment
5I am unemployed 
6I am no longer working 
Sheet857
Cell Formulas
RangeFormula
B1:B6B1=IF(ISNUMBER(LOOKUP(2,1/SEARCH(" "&{"work","job","furlough"}&" "," "&A1&" "))),"Employment","")
 
Upvote 0
Hi,

I'm thinking we should "Isolate" your key words in the text string, (e.g. the word "work" is inside "working", and "job" inside "jobless", etc.):

Book3.xlsx
AB
1I am not at work todayEmployment
2I'm currently jobless 
3I don't have a jobEmployment
4Is the furlough scheme still running?Employment
5I am unemployed 
6I am no longer working 
Sheet857
Cell Formulas
RangeFormula
B1:B6B1=IF(ISNUMBER(LOOKUP(2,1/SEARCH(" "&{"work","job","furlough"}&" "," "&A1&" "))),"Employment","")
Thank you guys, really helpful..
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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