Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating dummy values 1

Status
Not open for further replies.

mchoss

Programmer
Feb 11, 2002
87
0
0
GB
I am certain there is a simply way to do this but as yet, none of the excel functions i have looked up seem to do exactly what i am looking for:

Essentially i want to create a dummy value for each string in a list according to whether it is in some subset of this list. For example ...

If the subset is

red
blue

then i would like the following output

Value Dummy
Green 0
Yellow 0
Red 1
White 0
Blue 1
Black 0

Note, the list is long so ideally i would like to provide a cell range as the argument in which to search.

Any ideas?

Thanks in advance

 
Seems like an appropriate combination of IF, VLOOKUP and ISERR should do the trick.
 


Hi,

I'd suggest the MATCH function
[tt]
=if(iserror(match(A1,YourRedGreenRange,0)),0,1)
[/tt]


Skip,
[sub]
[glasses] [red]Be Advised![/red]
The band of elderly oriental musicians, known as Ground Cover, is, in reality...
Asian Jasmine![tongue][/sub]
 
Assuming your data is in A1:A1000 (Header in Row 1), and your subset range was in E1:E10, then in cell B2 put the following and copy down.

=COUNTIF($E$1:$E$10,A2)

Regards
Ken..............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
Indeed, all good ideas, thank to everyone who replied.

I had some success with the IF MATCH combination before i read these replies, but as you point out, it does leave you with the problem of having to clear up the #N/A ... i shall try out this ISERR and/or the COUNTIF functions.

Much appreciated
 
Ken,

The COUNTIF function is clearly the simplest and most succinct solution to my particular problem.

Thanks again
 
You're welcome. I like it because it gets rid of the need to account for #NAs :)

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top