Hello, everybody.
I'm trying to do a comparison between what the user inserted in this form:
And the values present in the last line of this table:
If all of them are equals, so the Excel will alert "this line was registered already", but if one or more value is different, than a new line is create with the values from the form.
I tried to do it using the folloing code:
But it isn't working properly. It is inserting new lines without following the condition.. I don't know how to fix it.
PS.: The text and images are in Portuguese.. I hope that it won't bother anyone..
Thank you all for the attention, in advanced.
I'm trying to do a comparison between what the user inserted in this form:
And the values present in the last line of this table:
If all of them are equals, so the Excel will alert "this line was registered already", but if one or more value is different, than a new line is create with the values from the form.
I tried to do it using the folloing code:
VBA Code:
ThisWorkbook.Sheets("cabos").Cells(1, 7).Select
Do Until IsEmpty(ActiveCell) = True
ActiveCell.Offset(1, 0).Select
r = r + 1
Loop
If Not ((ThisWorkbook.Sheets("cabos").Range("B" & r).Value = form_cabos.campo_regiao.Value) Or _
(ThisWorkbook.Sheets("cabos").Range("C" & r).Value = form_cabos.campo_endereco.Value) Or _
(ThisWorkbook.Sheets("cabos").Range("D" & r).Value = form_cabos.campo_relatorio.Value) Or _
(ThisWorkbook.Sheets("cabos").Range("E" & r).Value = form_cabos.campo_tipo.Value) Or _
(ThisWorkbook.Sheets("cabos").Range("F" & r).Value = form_cabos.campo_metragem.Value) Or _
(ThisWorkbook.Sheets("cabos").Range("G" & r).Value = form_cabos.campo_mesano.Value)) Then
ThisWorkbook.Sheets("cabos").Cells(r + 1, 2) = form_cabos.campo_regiao.Value
ThisWorkbook.Sheets("cabos").Cells(r + 1, 3) = form_cabos.campo_endereco.Value
ThisWorkbook.Sheets("cabos").Cells(r + 1, 4) = form_cabos.campo_relatorio.Value
ThisWorkbook.Sheets("cabos").Cells(r + 1, 5) = form_cabos.campo_tipo.Value
ThisWorkbook.Sheets("cabos").Cells(r + 1, 6) = form_cabos.campo_metragem.Value
ThisWorkbook.Sheets("cabos").Cells(r + 1, 7) = form_cabos.campo_mesano.Value
ID = ThisWorkbook.Sheets("cabos").Range("A" & r).Value + 1
ThisWorkbook.Sheets("cabos").Cells(r + 1, 1) = ID
Else
MsgBox "Item já cadastrado."
Exit Sub
End If
But it isn't working properly. It is inserting new lines without following the condition.. I don't know how to fix it.
PS.: The text and images are in Portuguese.. I hope that it won't bother anyone..
Thank you all for the attention, in advanced.