Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Find One Of Several Values Within A Cell

Is there a method to perform the following function?:
I) Using a list of values (In my case, these are text. For the discussion,
lets assume they are colors in 3 place format, like BLK, BLU, BRN, GRN, GRY,
RED, WHT, etc.).
II) Look in a cell, and see if any of those values exist (NOTE: There will
never be more than one of these values within a cell).
III) If any one of these values is found within the cell, state which value
it is.

For example, the statement might look like this:
=IF(FIND({any of the values listed},E2,1),{whatever value it found in
E2},Sorry Charlie) - where E2 is the Within Text location for the FIND
function.

I can accomplish this with nested IF functions, but this limits me to only
seven values.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default Find One Of Several Values Within A Cell

Jim J. wrote...
Is there a method to perform the following function?:
I) Using a list of values (In my case, these are text. For the discussion,
let's assume they are colors in 3 place format, like BLK, BLU, BRN, GRN, GRY,
RED, WHT, etc.).
II) Look in a cell, and see if any of those values exist (NOTE: There will
never be more than one of these values within a cell).
III) If any one of these values is found within the cell, state which value
it is.

....

=LOOKUP(2,1/COUNTIF(YourCellHere,"*"&YourListHere&"*"),YourLis tHere)

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Find One Of Several Values Within A Cell

Try this UDF:

Function ColorMe(r As Range) As String
s = Array("BLK", "BLU", "BRN", "GRN", "GRY", "RED", "WHT")
ColorMe = "Sorry Charlie"
For i = LBound(s) To UBound(s)
If InStr(r.Value, s(i)) Then
ColorMe = s(i)
Exit Function
End If
Next
End Function

--
Gary's Student


"Jim J." wrote:

Is there a method to perform the following function?:
I) Using a list of values (In my case, these are text. For the discussion,
lets assume they are colors in 3 place format, like BLK, BLU, BRN, GRN, GRY,
RED, WHT, etc.).
II) Look in a cell, and see if any of those values exist (NOTE: There will
never be more than one of these values within a cell).
III) If any one of these values is found within the cell, state which value
it is.

For example, the statement might look like this:
=IF(FIND({any of the values listed},E2,1),{whatever value it found in
E2},Sorry Charlie) - where E2 is the Within Text location for the FIND
function.

I can accomplish this with nested IF functions, but this limits me to only
seven values.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Find One Of Several Values Within A Cell

You can avoid VBA if the colors are standalone:
=IF(OR(A1="RED",A1="BLK",A1="BLU",A1="BRN",A1="GRN ",A1="GRY",A1="WHT"),A1,"sorry charlie")

--
Gary''s Student


"Jim J." wrote:

Is there a method to perform the following function?:
I) Using a list of values (In my case, these are text. For the discussion,
lets assume they are colors in 3 place format, like BLK, BLU, BRN, GRN, GRY,
RED, WHT, etc.).
II) Look in a cell, and see if any of those values exist (NOTE: There will
never be more than one of these values within a cell).
III) If any one of these values is found within the cell, state which value
it is.

For example, the statement might look like this:
=IF(FIND({any of the values listed},E2,1),{whatever value it found in
E2},Sorry Charlie) - where E2 is the Within Text location for the FIND
function.

I can accomplish this with nested IF functions, but this limits me to only
seven values.

  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default Find One Of Several Values Within A Cell

Gary''s Student wrote...
You can avoid VBA if the colors are standalone:

=IF(OR(A1="RED",A1="BLK",A1="BLU",A1="BRN",A1="GR N",A1="GRY",A1="WHT"),A1,
"sorry charlie")

....

Ugh! Brute force and entire cell content matching can be shortened to

=IF(OR(A1={"RED","BLK","BLU","BRN","GRN","GRY","WH T"}),A1,"not found")

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 96
Default Find One Of Several Values Within A Cell

Excuse for interrupting

Gary''s Student, maybe you can help me again for VBE, my today's ? post "SP
UDF for Excel in Excel Programming " - this one is for New Year's sake
....thanks from dribler2
http://www.microsoft.com/office/comm...g=en&cr=US&p=1
sign off...

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Find One Of Several Values Within A Cell

You are correct Harlan. This is the better formula, both compact and much
easier to expand. I'll file this away.
--
Gary's Student


"Harlan Grove" wrote:

Gary''s Student wrote...
You can avoid VBA if the colors are standalone:

=IF(OR(A1="RED",A1="BLK",A1="BLU",A1="BRN",A1="GR N",A1="GRY",A1="WHT"),A1,
"sorry charlie")

....

Ugh! Brute force and entire cell content matching can be shortened to

=IF(OR(A1={"RED","BLK","BLU","BRN","GRN","GRY","WH T"}),A1,"not found")


  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Find One Of Several Values Within A Cell

Maybe I misstated my needs. Lets try again:
I need to:
- Look into the contents of a cell, ex.: A12 (NOTE: Cell contents may be
100 characters)

- What I am looking for is any one of 5 values that I have listed in another
worksheet
- If I find any one of those values in A12 (will only be one of the 5
values), I want the function to report what value it found.
So, if my lookup values are BLK, BLU, GRN, RED, YEL, and if the
contents of A12 is: 782517 0010 Plnd I18-9BLK-002 01/02 18 Awg, .070 Dia .009
5.4646
then I want the function to tell me it found BLK

Thanks in advance!

"Gary''s Student" wrote:

You can avoid VBA if the colors are standalone:
=IF(OR(A1="RED",A1="BLK",A1="BLU",A1="BRN",A1="GRN ",A1="GRY",A1="WHT"),A1,"sorry charlie")

--
Gary''s Student


"Jim J." wrote:

Is there a method to perform the following function?:
I) Using a list of values (In my case, these are text. For the discussion,
lets assume they are colors in 3 place format, like BLK, BLU, BRN, GRN, GRY,
RED, WHT, etc.).
II) Look in a cell, and see if any of those values exist (NOTE: There will
never be more than one of these values within a cell).
III) If any one of these values is found within the cell, state which value
it is.

For example, the statement might look like this:
=IF(FIND({any of the values listed},E2,1),{whatever value it found in
E2},Sorry Charlie) - where E2 is the Within Text location for the FIND
function.

I can accomplish this with nested IF functions, but this limits me to only
seven values.



  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Find One Of Several Values Within A Cell

Maybe I misstated my needs. Lets try again:
I need to:
- Look into the contents of a cell, ex.: A12 (NOTE: Cell contents may be
100 characters)

- What I am looking for is any one of 5 values that I have listed in another
worksheet
- If I find any one of those values in A12 (will only be one of the 5
values), I want the function to report what value it found.
So, if my lookup values are BLK, BLU, GRN, RED, YEL, and if the
contents of A12 is: 782517 0010 Plnd I18-9BLK-002 01/02 18 Awg, .070 Dia .009
5.4646
then I want the function to tell me it found BLK

Thanks in advance!


"Harlan Grove" wrote:

Gary''s Student wrote...
You can avoid VBA if the colors are standalone:

=IF(OR(A1="RED",A1="BLK",A1="BLU",A1="BRN",A1="GR N",A1="GRY",A1="WHT"),A1,
"sorry charlie")

....

Ugh! Brute force and entire cell content matching can be shortened to

=IF(OR(A1={"RED","BLK","BLU","BRN","GRN","GRY","WH T"}),A1,"not found")


  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default Find One Of Several Values Within A Cell

Jim J. wrote...
Maybe I misstated my needs. Let's try again:

....

Dunno. Did you bother to try the formula

=LOOKUP(2,1/COUNTIF(YourCellHere,"*"&YourListHere&"*"),YourLis tHere)

where YourListHere could be either a defined name or an array constant
like

{"BLK","BLU","GRN","RED","YEL"}

or a reference to a range containing these values in separate cells?
That is, a formula like

=LOOKUP(2,1/COUNTIF(A12,"*"&{"BLK","BLU","GRN","RED","YEL"}&"* "),
{"BLK","BLU","GRN","RED","YEL"})

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
Cell References [email protected] Excel Discussion (Misc queries) 2 November 15th 06 11:37 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
find a cell matching separate column and row values LQEngineer Excel Worksheet Functions 2 July 26th 06 07:10 AM
Replacing Linked Cell Values w/ Current Values TomCat Excel Worksheet Functions 6 April 10th 06 12:20 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


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

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

About Us

"It's about Microsoft Excel"