Hi All

I have a code with error incompative values:

Sub Registro()

```
Dim x As Double
Dim sh As Worksheet
Dim V1 As Double
Dim V2 As Double
Set sh = ThisWorkbook.Sheets("Tabela Registros")
sh.Unprotect password:="Beto5651"
sh.Visible = xlSheetVisible
With sh
If Len(Userform1.txtValorArremat.Value) > 0 Then sh.Range("N2") = CDbl(Userform1.txtValorArremat)
If Len(Userform1.txtValorVenal.Value) > 0 Then sh.Range("O2") = CDbl(Userform1.txtValorVenal)
V1 = sh.Range("N3").Value
V2 = sh.Range("O3").Value
End With
If Len(Userform1.txtValorArremat.Value) > 0 And Len(Userform1.txtValorVenal.Value) > 0 And CDbl(Userform1.txtValorVenal) > CDbl(Userform1.txtValorArremat) _
Then x = V1
If Len(Userform1.txtValorArremat.Value) > 0 And Len(Userform1.txtValorVenal.Value) > 0 And CDbl(Userform1.txtValorVenal) < CDbl(Userform1.txtValorArremat) _
Then x = V2
Userform1.txtRegistro = x
Userform1.txtRegistro.Text = Format(Userform1.txtRegistro.Value, "R$ #,###0.00")
```

end sub

Do you know what I did wrong?