jeudi 29 juin 2017

If statement on Sheet Range

I am writing and Excel VBA if statement, but I can't figure out why it is not working.

I have 1 Sheet called "Data" and I want to check if some variables in column I are the same as in my ActiveSheet row 2, column B (which is number 2). I used the following code which ends automatically because it is not working. Anybody an idea?

Example:

Sub test()

If Sheets("Data").Range("I:I") = ActiveSheet(2, 2) Then
MsgBox ("Yes")
Else
MsgBox ("No")
End If

End Sub

Aucun commentaire:

Enregistrer un commentaire