mercredi 7 septembre 2016

Complicated if with and, or operators

*I want to create if statement, which would copy a value from one sheet to another if conditions are met. Logical test should be as following: 1. information should always be "not shared" 2. information should be "correct" and "correct" OR "correct" and "wrong" OR "wrong" and "correct" Below you may see the code with which I came so far:

    l = 2
For m = 2 To ElecRow
    If ele.Cells(m, 2) = "Not Shared" And _
           ele.Cells(m, 3) = "Correct" And gc.Cells(m, 3) = "Correct" _
        Or ele.Cells(m, 3) = "Correct" And gc.Cells(m, 3) = "Reading is wrong" _
        Or ele.Cells(m, 3) = "Reading is wrong" And gc.Cells(m, 3) = "Correct" Then
    For i = k + 4 To f + 4
    Selegas.Cells(l, 2).Value = ele.Cells(m, i).Value
    Selegas.Cells(l, 4).Interior.Color = RGB(179, 182, 184)
    l = l + 1
    Next i
    End If
Next m

However, the code is not working. Do you have any suggestions?

Aucun commentaire:

Enregistrer un commentaire