Search string in range of cells and display full cell contents

BoyScout

New Member
Joined
Oct 8, 2008
Messages
4
Hi,

I need to search a range of cells for a given string of text and display the cell contents for any cells in the row which contain the search criteria.

Example:-
String to search is entered in B15. I need it to search each row and display (in column G) the full data for the match. No more than one cell in each row will contain matching data.
A</SPAN>
B</SPAN>
C</SPAN>
D</SPAN>
E</SPAN>
F</SPAN>
G</SPAN>
H</SPAN>
1</SPAN>
Machine</SPAN>
User 1</SPAN>
User 2</SPAN>
User 3</SPAN>
User 4</SPAN>
User 5</SPAN>
Full text of cell containing
the Search String</SPAN>

Desired result in
column G</SPAN>

2</SPAN>
Alpha</SPAN>
ghl.792.c7x</SPAN>
abc.587.k2g</SPAN>
alt.982.g5z</SPAN>
qly.496.b6s</SPAN>
qpn.735.y1h</SPAN>
What is the Formula?</SPAN>
abc.587.k2g</SPAN>
3</SPAN>
Bravo</SPAN>
own.731.h6x</SPAN>
rmx.183.w4h</SPAN>
wpz.388.g2s</SPAN>
abc.584.w6c</SPAN>
abc.587.w7f</SPAN>
What is the Formula?</SPAN>
abc.587.w7f</SPAN>
4</SPAN>
Charlie</SPAN>
abc.589.w7l</SPAN>
alm.921.w8j</SPAN>
abc.587.h8e</SPAN>
vxn.741.w6k</SPAN>
qnp.552.l1c</SPAN>
What is the Formula?</SPAN>
abc.587.h8e</SPAN>
5</SPAN>
Delta</SPAN>
arc.365.y4d</SPAN>
wpv.714.r2d</SPAN>
qpk.795.e1a</SPAN>
adc.587.w8h</SPAN>
whr.198.v5o</SPAN>
What is the Formula?</SPAN>
6</SPAN>
Echo</SPAN>
abc.587.l1j</SPAN>
pwm.735.t1s</SPAN>
jhm.726.w3w</SPAN>
mkn.723.b6b</SPAN>
ops.717.s2t</SPAN>
What is the Formula?</SPAN>
abc.587.l1j</SPAN>
7</SPAN>
Foxtrot</SPAN>
asg.356.w6d</SPAN>
lfr.483.j4v</SPAN>
pfd.587.h5f</SPAN>
abc.587.p7t</SPAN>
alt.460.w8j</SPAN>
What is the Formula?</SPAN>
abc.587.p7t</SPAN>
8</SPAN>
Golf</SPAN>
lai.234.l2h</SPAN>
own.481.a7g</SPAN>
wkd.789.d1o</SPAN>
wnp.180.g3f</SPAN>
oqm.193.r6s</SPAN>
What is the Formula?</SPAN>
9</SPAN>
Hotel</SPAN>
aiw.491.w0h</SPAN>
odv.358.s8f</SPAN>
abc.587.v3b</SPAN>
wno.734.h5h</SPAN>
qpn.715.y2j</SPAN>
What is the Formula?</SPAN>
abc.587.v3b</SPAN>
14</SPAN>
15</SPAN>
Search String</SPAN>
abc.587</SPAN>

<TBODY>
</TBODY>


Can this be done with a formula or does it need some sort of macro? (Macro's are completely foreign to me!)

Many thanks,
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Assuming that there are only 5 users overall, the below formula does what you're looking for I believe:
MachineUser 1User 2User 3User 4User 5Full text of cell containing the search stringDesired Result
Alphaghl.792.c7xabc.587.k2galt.982.g5zqly.496.b6sqpn.735.y1habc.587.k2gabc.587.k2g
Bravoown.731.h6xrmx.183.w4hwpz.388.g2sabc.584.w6cabc.587.w7fabc.587.w7fabc.587.w7f
Charlieabc.589.w7lalm.921.w8jabc.587.h8evxn.741.w6kqnp.552.l1cabc.587.h8eabc.587.h8e
Deltaarc.365.y4dwpv.714.r2dqpk.795.e1aadc.587.w8hwhr.198.v5oMissing
Echoabc.587.l1jpwm.735.t1sjhm.726.w3wmkn.723.b6bops.717.s2tabc.587.l1jabc.587.l1j
Foxtrotasg.356.w6dlfr.483.j4vpfd.587.h5fabc.587.p7talt.460.w8jabc.587.p7tabc.587.p7t
Golflai.234.l2hown.481.a7gwkd.789.d1ownp.180.g3foqm.193.r6sMissing
Hotelaiw.491.w0hodv.358.s8fabc.587.v3bwno.734.h5hqpn.715.y2jabc.587.v3babc.587.v3b
Search Stringabc.587

<tbody>
</tbody><colgroup><col span="8"></colgroup>



Machine starts in Cell A1, Row 2 is Blank, Info continues in Row 3. Search String is in cell B12.

Formula in G3: =IF(LEFT(B3,7)=$B$12,B3,IF(LEFT(C3,7)=$B$12,C3,IF(LEFT(D3,7)=$B$12,D3,IF(LEFT(E3,7)=$B$12,E3,IF(LEFT(F3,7)=$B$12,F3,"Missing")))))

Copy down to cover all rows. This also adds "Missing" if the string is not seen in the row. There is most likely a better way to do this, but this is what I was able to come up with.
 
Upvote 0
Here's one way:


Excel 2010
ABCDEFGH
1MachineUser 1User 2User 3User 4User 5Full text of cell containingDesired result in
2the Search Stringcolumn G
3Alphaghl.792.c7xabc.587.k2galt.982.g5zqly.496.b6sqpn.735.y1habc.587.k2gabc.587.k2g
4Bravoown.731.h6xrmx.183.w4hwpz.388.g2sabc.584.w6cabc.587.w7fabc.587.w7fabc.587.w7f
5Charlieabc.589.w7lalm.921.w8jabc.587.h8evxn.741.w6kqnp.552.l1cabc.587.h8eabc.587.h8e
6Deltaarc.365.y4dwpv.714.r2dqpk.795.e1aadc.587.w8hwhr.198.v5o
7Echoabc.587.l1jpwm.735.t1sjhm.726.w3wmkn.723.b6bops.717.s2tabc.587.l1jabc.587.l1j
8Foxtrotasg.356.w6dlfr.483.j4vpfd.587.h5fabc.587.p7talt.460.w8jabc.587.p7tabc.587.p7t
9Golflai.234.l2hown.481.a7gwkd.789.d1ownp.180.g3foqm.193.r6s
10Hotelaiw.491.w0hodv.358.s8fabc.587.v3bwno.734.h5hqpn.715.y2jabc.587.v3babc.587.v3b
11
12Search Stringabc.587
Sheet3
Cell Formulas
RangeFormula
G3=IFERROR(HLOOKUP("*"&$B$12&"*",$B3:$F3,1,0),"")
 
Upvote 0
Thanks Firefly2012. That looks like the sort of thing I was expecting, but unfortunately I get a '#NAME?' error when I try this. I am using XP and Excel 2003. I'm not sure if that makes a difference? - I can't find IFERROR in the function list, so I guess that's the reason.
 
Upvote 0
Yes - IFERROR is only available from xl2007+

Instead you could use:

=IF(ISNA(HLOOKUP("*"&$B$12&"*",$B3:$F3,1,0)),"",HLOOKUP("*"&$B$12&"*",$B3:$F3,1,0))
 
Upvote 0

Forum statistics

Threads
1,203,212
Messages
6,054,190
Members
444,708
Latest member
David R__

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