Extract simple string from array of complex cells

Turk182

Board Regular
Joined
Sep 9, 2009
Messages
66
Office Version
  1. 365
Platform
  1. MacOS
Hello, I need help combining Excel functions to do 2 things:

  1. Search for the SIMPLE food names (like BEEF
SALMON

CHICKEN) on my personal food list—sheet2 colA

WITHIN sheet1 colA’s COMPLEX
strings—(like

Shoulder roast, BEEF, visible fat eaten

Fish, wild-caught, SALMON, sockeye, pan-seared

CHICKEN, breast meat, Skinless, baked
; and then

2. When the simple name is found, I need the
6-item contents of—sheet1 column B (100g 125 22 8 0 0)
to spill across the very next 6 columns (B:G) of sheet2, next to (same row as) the simple food name

Thx
I appreciate any potential solutions.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach screenshots (not pictures) of your two sheets. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
Sheet1
1693447503668.png


Sheet2
1693447636333.png


Thank you very much. Above are the range examples from each of the 2 spreadsheets. The Mr. Excel button is not working.
 
Upvote 0
Assuming that your food names start on row 9 of Sheet2, try:
VBA Code:
Sub ExtractString()
    Application.ScreenUpdating = False
    Dim srcWS As Worksheet, desWS As Worksheet, food As Range, fnd As Range, portion As Variant
    Set srcWS = Sheets("Sheet1")
    Set desWS = Sheets("Sheet2")
    With desWS
        For Each food In .Range("A9", .Range("A" & .Rows.Count).End(xlUp))
            Set fnd = srcWS.Range("A:A").Find(food, LookIn:=xlValues, lookat:=xlPart)
            If Not fnd Is Nothing Then
                portion = Split(fnd.Offset(, 1), " ")
                food.Offset(, 1).Resize(, 6).Value = Array(portion(0), portion(1), portion(2), portion(3), portion(4), portion(5))
            End If
        Next food
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks mumps. My food names do start on row 9 of Sheet2. However, I was wondering if there might be solution using Excel functions/formulas....
 
Upvote 0
How about
Excel Formula:
=TEXTSPLIT(XLOOKUP("*"&A9&"*",Sheet1!A2:A100,Sheet1!B2:B100,"",2)," ")
 
Upvote 0
Solution

Forum statistics

Threads
1,215,102
Messages
6,123,097
Members
449,096
Latest member
provoking

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