jeudi 27 avril 2017

multiple if statement conditions vba

I'm very new to VBA so need a little help. I have a macro (BEM) that is dependent on the value of two cells. I want to be able to run the macro if either of those values is changed. If either of them is blank, I need the code to do nothing until a value is inputted in both cells.

Here's what I have so far but it doesn't seem to work:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$B$3" Or Target.Address = "$B$4" And (IsEmpty(Range("B3").Value) Or IsEmpty(Range("B4").Value)) Then
        Exit Sub
    Else
        BEM
    End If
End Sub

Aucun commentaire:

Enregistrer un commentaire