I need to compare the value of the last filled cell with the antepenultimate

Asked

Viewed 124 times

1

ola thank you for your attention.

I need to compare the value of the last filled cell with the antepenultimate. if the value is different I want to continue with the current value if seje = place the word error

this is being necessary because in my code is loading the result of the previous search

.Document.all("cpf").innerText = Range("a" & linha)

.Document.all("btn_consultar").Click

Application.Wait (Now + TimeValue("00:00:01"))

Range("g" & linha) = IE.Document.all("teste1").innerText
Range("b" & linha) = IE.Document.all("teste2").innerText
Range("d" & linha) = IE.Document.all("teste3").innerText
Range("e" & linha) = IE.Document.all("teste"5).innerText
Range("f" & linha) = IE.Document.all("tesste2").innerText
Range("g" & linha) = IE.Document.all("5353fsf").innerText

menos1 = linha - 1
linha = linha + 1

MsgBox ("linha")
MsgBox ("menos1")

Application.Wait (Now + TimeValue("00:00:01"))





Wend
      Wend
          Wend

  End With


End Sub
  • Thays good evening, this comparison is in column or row, in this range have blank cells?

  • hi paulo good night, are in column and a sequence of Cpf that I play in the system and returns me a value in the cell Range("d" & line) = IE.Document.all("msisdnClient"). innerText however the result is repeating when negative. then I would like to compare the result with the previous line if it is equal to the previous one to fill in with error or something like that

1 answer

1

Thays hope the code snippet helps

If linha >= 2 And Range("D" & linha).Value <> Empty Then
'inicia comparação a partir da linha 2, já que a comparação é entre a linha atual e a atual-1
    If Range("D" & linha - 1).Value = Range("D" & linha).Value Then
        '<seu código aqui>
        Debug.Print Range("D" & linha).Value, Range("D" & linha).Address
    End If
End If

Browser other questions tagged

You are not signed in. Login or sign up in order to post.