If Statement Query

  • Me again


    Another If problem... along the same lines... :mad:


    I am trying to check if a cell has either of the following values...
    "0,"
    "00,"
    " " (2 spaces)
    " " (4 spaces)


    If it has, then return "No;" and a wrap-line return. If none, then leave blank.


    My formula below is not working - it works for those that have the zeros in:
    =IF(OR('Sheet1'!W13="0,",'Sheet1'!W13="00,",'Sheet1'!W13=" ",'Sheet1'!W13=" "),"No;"&CHAR(10),"")


    Any ideas on what I am doing wrong..? :(


    thanks

  • Re: If Statement Query


    Hi dugong,


    Are you putting 2 spaces and 4 spaces in your formula? It looks like just one space in each part of the formula.


    Bill


    EDIT:


    =IF(OR('Sheet1'!W13="0,",'Sheet1'!W13="00,",'Sheet1'!W13=" ",'Sheet1'!W13=" "),"No;"&CHAR(10),"")


    With 2 spaces and 4 spaces in the formula, it works for me.

  • Re: If Statement Query


    It could have been the way extra spaces get lost in the normal font in here, which is why I have put code tags in, unusually for me. Try pasting this, it works for me:


    Code
    =IF(OR(Sheet1!W13="0,",Sheet1!W13="00,",Sheet1!W13="  ",Sheet1!W13="    "),"No;"&CHAR(10),"")
  • Re: If Statement Query


    or more readable and thus more maintainable


    Code
    Select Case Sheet1!W13
    Case "0,", "00,", "  ", "    "
        strReturn ="No;" & vbCrLf
    Case Else
        strReturn =""
    End Select


    Regards,


    J.

  • Re: If Statement Query



    Or even more readable:


    Code
    Select Case Sheet1!W13
    Case "0,", "00,", Space(2), Space(4)
        strReturn ="No;" & vbCrLf
    Case Else
        strReturn =""
    End Select


    Regards


    Rich

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!