On 2002-08-24 12:41, JimCWalker wrote:
I want to develop a spread sheet in excel that has some questions that can be answered "yes" or "no". I then want to be able to convert these to 1 and 0 respectively so I can use them in some formulas. I realize that I could just tell the users to use 1 for yes and 0 for no but I was hoping that there was a more "elegent" way to do this.
Jim
( 1.) Activate Insert|Name|Define.
( 2.) Enter
Yes in the Names in Workbook box.
( 3.) Enter the following in the Refers to box:
1
( 4.) Click Add.
( 5.) Enter
No in the Names in Workbook box.
( 6.) Enter the following in the Refers to box:
0
( 7.) Click OK.
( 8.) Download the morefunc add-in from
http://longre.free.fr/english/index.html
and install/activate the add-in via Tools|Add-Ins.
If your users cannot somehow install this add-in, then add the following code to your WB:
Function Eval(Arg As String) As Variant
Eval = Evaluate(Arg)
End Function
I believe the EVAL from morefunc to be faster...
The foregoing makes it possible that you can apply formulas to ranges housing a bunch of Yes and/or No like in:
=SUM(EVAL(A1:A2))
=AVERAGE(EVAL(A1:D1))
=COUNT(EVAL(A1:D1))
but also...
=COUNTA(A1:D1)
=COUNTIF(A1:D1,"yes")
See the figure...
aaSymsInFormulas JimCWalker.xls |
---|
|
---|
| A | B | C | D |
---|
1 | yes | yes | yes | no |
---|
2 | no | | | |
---|
3 | 1 | | | |
---|
4 | 0.75 | | | |
---|
5 | 4 | | | |
---|
6 | 4 | | | |
---|
7 | 3 | | | |
---|
8 | | | | |
---|
|
---|
This message was edited by Aladin Akyurek on 2002-08-24 13:37