lundi 28 août 2017

If statement skipping outcome action

I've got a problem that I'm struggling to make sense of and I'm hoping you guys can assist.

My if statement is not executing the action for a true result and I'm not sure why. I have used a similar condition earlier in the code and there were no issues.

here's the section of the code that I'm struggling with:

Dim Descr1 as String, Descr2() as String, Descr3() as String
Dim erow1 as Long
Dim I as Long
Dim p as Long
Dim q as Long

erow1 = Sheets("report").Cells(1, 1).CurrentRegion.Rows.Count + 1

If Descr1 = Trim(Descr3(q)) And Descr1 = Trim(Descr2(p)) Then
                ThisWorkbook.Sheets("report").Cells(erow1, 1) = WS1.Cells(i, "b")
                ThisWorkbook.Sheets("report").Cells(erow1, 2) = WS1.Cells(i, "c")
            Else
           End If
        Next q
        Next p

I'm getting a true condition but the cells information is not coming through into the intended sheet. I'm really stunned, please help.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire