Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default comparing a value to a list

i need to check if the value of a cell is contained within a list
ex:
cell.value is "apple"
the list is stored as a range of cells, and is something like: "apple",
"pear", "lemon"
so the result would be TRUE (apple is in the list)
however, if the cell value was "grapefruit', the result would be FALSE
------------------------------------
i would normally go thru the list using Find(), and FindNext(); if the value
is found, =TRUE; if nothing =FALSE...

the problem is that i'm already inside a FindNext() loop; so i get a
conflict between the search string in the inner loop and the outer loop,
which is being re-defined by the inner loop
-------------------------------------
the list is not long, so i could do:
if cell = range(a1)... or cell = range(a2)... or cell = range(a3)... or ...
this seems to not be the most efficient way to do this
-------------------------------------
i could also loop through each cell in the list comparing it's value to the
searach string
but, again, i think that there must be a more elegant solution (i think ?)

mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default comparing a value to a list

mark kubicki wrote:

i need to check if the value of a cell is contained within a list
ex:
cell.value is "apple"
the list is stored as a range of cells, and is something like: "apple",
"pear", "lemon"
so the result would be TRUE (apple is in the list)
however, if the cell value was "grapefruit', the result would be FALSE
------------------------------------
i would normally go thru the list using Find(), and FindNext(); if the value
is found, =TRUE; if nothing =FALSE...

the problem is that i'm already inside a FindNext() loop; so i get a
conflict between the search string in the inner loop and the outer loop,
which is being re-defined by the inner loop
-------------------------------------
the list is not long, so i could do:
if cell = range(a1)... or cell = range(a2)... or cell = range(a3)... or ...
this seems to not be the most efficient way to do this
-------------------------------------
i could also loop through each cell in the list comparing it's value to the
searach string
but, again, i think that there must be a more elegant solution (i think ?)


What about using VLOOKUP and check if the result is #N/A with ISNA?

Regadrs,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.

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
Comparing List A to List B and add what's missing from List B Gilbert Excel Discussion (Misc queries) 2 July 20th 09 11:18 PM
Comparing List A to List B and add what's missing from List B Gilbert Excel Discussion (Misc queries) 1 July 20th 09 08:41 PM
comparing names in a list ferde Excel Discussion (Misc queries) 6 March 22nd 06 05:11 AM
Comparing 2 list IFIXPCS Excel Discussion (Misc queries) 4 February 21st 06 10:43 PM
Comparing value to list Bob F[_3_] Excel Programming 6 October 15th 03 01:25 AM


All times are GMT +1. The time now is 06:54 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"