Empty cell true or false

  • Hi, I am Looking for a solution. know the fact but could not arrange the code in the right way. Hope someone helps me.


    I have two cells "O20" and "Q20"


    If "O20" and "Q20" both have non-number values or are empty then it will run code

    If "O20" and "Q20" both have number values then it will run code

    If "O20" is empty or has a non-number value and "Q20" have number values then it will exit or show error info

    If "O20" has number values and "Q20" is empty or has a non-number value then it will exit or show error info


    I tried

    Code
    If IsEmpty(Range("O20").Value) = False Or IsEmpty(Range("Q20").Value) = True Then GoTo ErrorHandle
    If IsEmpty(Range("O20").Value) = True Or IsEmpty(Range("Q20").Value) = False Then GoTo ErrorHandle
    
    If IsEmpty(Range("O20").Value) = True Or IsEmpty(Range("Q20").Value) = True Then
    If IsEmpty(Range("O20").Value) = False Or IsEmpty(Range("Q20").Value) = False Then

    but failed to achieve the result.


    Hope someone help.


    Thanks in advance

  • Hello

    Try this macro

    Code
    Sub prova()
    If ((IsEmpty(Range("O20")) Or Not IsNumeric(Range("O20"))) And IsNumeric(Range("Q20"))) Or _
    (IsNumeric(Range("O20")) And (IsEmpty("Q20") Or Not IsNumeric(Range("Q20")))) Then
    GoTo ErrorHandle
    End If
    'run code
    End Sub

    Hi,

    Mario

Participate now!

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