Comparing two rows in Excel for a particular word and returning the content found in that cell where the word is in a new row

Sailadarohit

New Member
Joined
Sep 7, 2022
Messages
39
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
I want to compare two rows in Excel for a particular word and return the entire content found in that cell where the word is present in the new rows.
So i am searching with the word nike in the two rows, the formula should search both the rows for the word nike and if found return the entire content found along with the word nike in the new rows else return NULL.
Row A and B are my inputs, output should look like row C and D
Please refer the attachment for more information.
 

Attachments

  • word_finding.jpg
    word_finding.jpg
    40.9 KB · Views: 12
I have tried doing this for adding XL2BB but microsoft is not allowing me to use that..
Try putting the Add-In into a 'Trusted Location'

Could the word being searched for ever appear more than once in a cell--No it won't appear
Thanks for that clarification.


What about this though?
The word is always preceded by an underscore but not always we can assume that is followed by an underscore.
So, could we have some sample data and expected results that show the variety that can occur?
From what I can see in your latest image, every occurrence of "nike" (& "puma") is preceded and followed by an underscore.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
From what I can see in your latest image, every occurrence of "nike" (& "puma") is preceded and followed by an underscore.-- Yes we can assume this and formulate the solution accordingly.
Pls ignore my previous statement related to this.

Thanks in advance
 
Upvote 0
Try this then

Sailadarohit_1.xlsm
ABCD
1ActualAssumedWordPresent ActualWordPresent Assumed
2Dress, brand_nike_costly_new, StoreJeans, brand_nike_air_cheap_Used, Onlinebrand_nike_costly_newbrand_nike_air_cheap_Used
3Online, brand_puma_shirt, PaidStore, brand_puma_jeans, ReturnNULLNULL
4Offline, brand_nike_jeans, CardShirt, brand_nike_tshirtsbrand_nike_jeansbrand_nike_tshirts
5Dress, brand_moniker_costly_new, StoreJeans, brand_moniker_costly_newNULLNULL
Sheet1
Cell Formulas
RangeFormula
C2:D5C2=IFERROR(REPLACE(LEFT(A2,FIND(",",A2&",",SEARCH("_nike_",A2))-1),1,FIND(",",A2)+1,""),"NULL")
 
Upvote 0
Thank you so much.. there is a last case which needs to be addressed, in some cases a single string can be present without any commas which can have the key word, the current formula does not address that like for example. Please help

Actual Assumed Word Present Actual Word Present Assume
black_nike_pro black_nike_beta black_nike_pro black_nike_beta
 
Upvote 0
Thank you so much.. there is a last case which needs to be addressed, in some cases a single string can be present without any commas which can have the key word, the current formula does not address that like for example. Please help

Actual Assumed Word Present Actual Word Present Assume
black_nike_pro black_nike_beta black_nike_pro black_nike_beta

Please find the attached image where the nike word is not proceeded by underscore also the case where a single string can be present without any commas which can have the search word, our formula must accomodate these as well
 

Attachments

  • nike.PNG
    nike.PNG
    7.2 KB · Views: 6
Upvote 0
nike word is not proceeded by underscore
You did say to ignore that. :(
is preceded and followed by an underscore.-- Yes we can assume this and formulate the solution accordingly.
Pls ignore my previous statement related to this.


also the case where a single string can be present without any commas which can have the search word, our formula must accomodate these as well
Then examples like that should have been provided to start with. :(

You can try this but if there is nothing to mark the end of the searched word, you could get false returns - see row 9

Sailadarohit_1.xlsm
ABCD
1ActualAssumedWordPresent ActualWordPresent Assumed
2Dress, brand_nike_costly_new, StoreJeans, brand_nike_air_cheap_Used, Onlinebrand_nike_costly_newbrand_nike_air_cheap_Used
3Online, brand_puma_shirt, PaidStore, brand_puma_jeans, ReturnNULLNULL
4Offline, brand_nike_jeans, CardShirt, brand_nike_tshirtsbrand_nike_jeansbrand_nike_tshirts
5Dress, brand_moniker_costly_new, StoreJeans, brand_moniker_costly_newNULLNULL
6black_nike_problack_nike_betablack_nike_problack_nike_beta
7online,black_nike_problack_nike_airblack_nike_problack_nike_air
8offline,red_nike,pantsshop,red_nike_air,shirtsred_nikered_nike_air
9offline,red_nikersly,pantsshop,red_nikersly_air,shirtsred_nikerslyred_nikersly_air
Sheet1
Cell Formulas
RangeFormula
C2:D9C2=IFERROR(TRIM(REPLACE(LEFT(A2,FIND(",",A2&",",SEARCH("_nike",A2))-1),1,IFERROR(FIND(",",LEFT(A2,SEARCH("_nike",A2))),0),"")),"NULL")
 
Upvote 0
Thank you so much peter
And sorry for not being able to provide all use cases once because unfortunately they keep on adding
For case 9 i think i can manage that as the probability of getting such is less
 
Upvote 0
Thanks Peter, This worked very well. Given a scenerio if the nike word is present in the 3rd or 4th or any other position how to update the formula
 
Upvote 0
.. so the rules have changed again!! :eek:

If you can give a set of sample data containing all the different variations possible, including those already covered and any new ones, and the expected answer for each one in a form that I can copy to test with I will consider having a look at it.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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