English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am looking for a formula or way to do the following in Excel:

I have a value, and I want to see if it is contained in an array. I just want a 1 or 0 if it is in the array or not. I could use any of the LOOKUP functions, but they return error messages when the value is not found.

Example:

Array:
101
102
103
104
105

For the value 101, I would like a "1", because it is contained in the array. For the value 108, I would like a 0 (or anythng else I can flag) because it is not contained in the array...

Any ideas?

2006-07-12 03:46:28 · 6 answers · asked by Q&A_Boy 2 in Computers & Internet Software

6 answers

Assuming your "Value" is in cell A1 and your "Array" is in "B1:B5" then the following formula in cell C1 would give you your desired flag. Hold cursor over formula to display entire formula.
=IF(ISERROR(VLOOKUP(A1,B1:B5,1,FALSE))=FALSE,1,0)

2006-07-12 03:56:40 · answer #1 · answered by Jett1331 1 · 0 0

SQL would probably be best in this situation. You could use Microsoft Acess to store you list of numbers (arrays) you would write an SQL query to search the array. It would be something like this.....

Select * from Table1
Where Array=Number

Where Array is the name of the table heading and the Number is the number your searching. You can write a stored procedure to return a 0 or 1 and applicable.

2006-07-12 10:51:16 · answer #2 · answered by Anonymous · 0 0

What exactly are you searching for in this array??

Surely you need to just adapt:

If (B6 = '101' THEN 1 else 0)

2006-07-12 10:49:52 · answer #3 · answered by the_dt 4 · 0 0

I don't know but I suggest, for programming questions, use the programming newsgroups, you will find answers easier. Go to this page:

http://groups.google.com/groups/dir?lnk=hpsfg&hl=en&q=excel

Try the groups called:
microsoft.public.excel
microsoft.public.excel.programming

2006-07-12 10:56:08 · answer #4 · answered by Trinzzia 2 · 0 0

the funcion you are wanting to use is VLOOKUP, within an IF clause ; check it out in EXCEL help. very powerful

2006-07-12 10:50:49 · answer #5 · answered by THX1138 4 · 0 0

Try This
IF(ISERROR(VLOOKUP
(lookupvalue,Array,1,FALSE)),
0,1)

This might be fits your suits

2006-07-14 16:48:50 · answer #6 · answered by Piyush 2 · 0 0

fedest.com, questions and answers