logo elektroda
logo elektroda
X
logo elektroda

Adding Multiple Conditions to an Excel VBA IF Statement for Cells F6, H6

karolczyzycki 15951 5
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 7018505
    karolczyzycki
    Level 20  
    Hello.
    How in such an IF loop, add a few more conditions?
    At this point, error is shown if cell F6 is empty.
    How do I add a few more cells to this condition?
    my code:
    
    If (Range("F6") = "") Then
    Range("N6") = "Błąd"
    Else
    ..........
    end if

    This doesn't work:
    If (Range("F6,H6") = "") Then

    nor this:
    If (Range("F6" & "H6") = "") Then

    If it adds cells after the decimal point, it only satisfies the first condition, if I type "&" I get an error.
    What should I type in to make this work as a product of terms?
  • ADVERTISEMENT
  • #2 7018610
    Czybyszew
    Level 20  
    If (Range("F6") = "") and (Range("H6") = "") and (Range("J6") = "") Then .....
  • ADVERTISEMENT
  • #3 7018651
    karolczyzycki
    Level 20  
    This code also throws an error:
    Quote:
    Run-time error '13':
    Type mismatch
  • ADVERTISEMENT
  • #4 7018706
    Czybyszew
    Level 20  
    It may be so
    If Range("F6") = "" and Range("H6") = "" and Range("J6") = "" Then .....
    and if not that
    If (Range("F6") = "" and Range("H6") = "" and Range("J6") = "" ) Then .....
    I haven't used VB for a long time, but in Pascal-type languages, conditions are joined by "and" and "or", etc.
  • ADVERTISEMENT
  • #5 7019010
    Dżyszla
    Level 42  
    AND na - just F1 in the editor ;)
ADVERTISEMENT