Return a value of '1' a referenced cell is empty

前端 未结 9 462
闹比i
闹比i 2020-12-17 07:47

In Excel, I need to return a value of 1 if a referenced cell is empty

I can do it if the value is zero but how do I do it if it is empty?

相关标签:
9条回答
  • 2020-12-17 07:56

    You may have to use =IF(ISNUMBER(A1),A1,1) in some situations where you are looking for number values in cell.

    0 讨论(0)
  • 2020-12-17 08:02

    P4 is the cell I test for:

    =IF(ISBLANK(P4),1,0)
    
    0 讨论(0)
  • 2020-12-17 08:06
    =if(a1="","1","0")
    

    In this formula if the cell is empty then the result would be 1 else it would be 0

    0 讨论(0)
  • 2020-12-17 08:07

    Paxdiablo's answer is absolutely correct.

    To avoid writing the return value 1 twice, I would use this instead:

    =IF(OR(ISBLANK(A1),TRIM(A1)=""),1,0)
    
    0 讨论(0)
  • 2020-12-17 08:08

    Since required quite often it might as well be brief:

    =1*(A1="")
    

    This will not return 1 if the cell appears empty but contains say a space or a formula of the kind =IF(B1=3,"Yes","") where B1 does not contain 3.

    =A1="" will return either TRUE or FALSE but those in an equation are treated as 1 and 0 respectively so multiplying TRUE by 1 returns 1.

    Much the same can be achieved with the double unary --:

    =--(A1="")  
    

    where when A1 is empty one minus negates TRUE into -1 and the other negates that to 1 (just + in place of -- however does not change TRUE to 1).

    0 讨论(0)
  • 2020-12-17 08:13

    If you've got a cell filled with spaces or blanks, you can use:

    =Len(Trim(A2)) = 0
    

    if the cell you were testing was A2

    0 讨论(0)
提交回复
热议问题