Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Search Cell Contents Between ||

I have cells that contain a list seperated by || (i.e.
|cat|dog|fish|ape|). I am looking for options to search thru this list
for a particular item. I know I can to a text to column and then
search each of the resulting individual cells for say dog, but I am
looking for an easier way. The problem with text to column is that
some of the cells have only one item whereas others have 8, so it gets
messy. Using a formula, can I chop up the string into an array and
then search the array elements for a particular string?

-Andrew V. Romero

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Search Cell Contents Between ||

You might try some code like the following:


Dim Rng As Range
Dim Arr As Variant
Dim S As String
Set Rng = Range("A1")
S = Trim(Rng.Text)
If Left(S, 1) = "|" Then
S = Mid(S, 2)
End If
If Right(S, 1) = "|" Then
S = Left(S, Len(S) - 1)
End If
Arr = Split(S, "|")
Range("B1").Resize(1, UBound(Arr) - LBound(Arr) + 1).Value = Arr




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
oups.com...
I have cells that contain a list seperated by || (i.e.
|cat|dog|fish|ape|). I am looking for options to search thru
this list
for a particular item. I know I can to a text to column and
then
search each of the resulting individual cells for say dog, but
I am
looking for an easier way. The problem with text to column is
that
some of the cells have only one item whereas others have 8, so
it gets
messy. Using a formula, can I chop up the string into an array
and
then search the array elements for a particular string?

-Andrew V. Romero



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Search Cell Contents Between ||

I got to thinking more, and I can probably just use the search formula,
then it returns a number, I know I found the string I was looking for.
If it returns a null, my item was not found. Thanks for the code , I
will also take a look at it.

-Andrew V. Romero

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SEARCH but for cell contents rather than text Matt D Francis Excel Discussion (Misc queries) 2 October 29th 09 02:45 PM
Can I search for the displayed value in a cell, not the contents? Eric_NY Excel Discussion (Misc queries) 2 July 14th 09 04:19 PM
search if cell contents exist in other cells CharileBaker Excel Worksheet Functions 1 April 12th 07 11:00 AM
search Sheet2! for the contents of Sheet1! Fester Excel Discussion (Misc queries) 8 November 11th 06 01:09 AM
Search Through Multiple Tabs' Contents mayers57 New Users to Excel 1 June 22nd 06 01:48 AM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"