2

Most likely pretty straight forward this, but it's got me stumped.

I have a cell in Excel (say C1) which has a text value of "W0-1". I then have a formula in cell D1 of

=MID(C1,2,1)

and a formula of

=MID(C1,4,1)

in cell E1.

This basically strips out the numeric values of the text into two new columns, of home goals and away goals.

I then have another column (column F) that i want to populate with 1 or 0 based on the values of D1 and E1 being above 0. The formula I entered is :

=IF(AND(D1>0,E1>0),1,0)

however in the above case this returns 1, when it should return 0, as the value in D1 is 0.

It appears that the IF formula is not interpreting the value in D1 as 0. If i manually enter the figures in D1 and E1 as 0 and 1 my IF formula works correctly, so is this something I am doing wrong in the MID formula?

Thanks

4

3 回答 3

3

您的 D1 和 E1 列可能都是正在保存的字符串。

用 VALUE 函数包装您的 MID 函数以将它们转换为整数。

VALUE(MID(C1,2,1))
于 2013-05-13T14:07:14.460 回答
2

公式的小改动

Cell D1 = VALUE(MID(C1,2,1)) 
Cell E1 = VALUE(MID(C1,4,1))

由于函数MID(text,start_num,num_chars)返回一个字符串

于 2013-05-13T14:11:59.190 回答
1

这应该工作...

=IF(AND(D1<>"0",E1<>"0"),1,0)

公式正在返回文本,您的 IF() 正在寻找数字。这也行,

=IF(AND(D1="1",E1="1"),1,0)
于 2013-05-13T14:11:43.077 回答