Private Sub Cmd_Transfert_Click()
Dim LastLig As Long, x As String, C As Range, i As Integer
With Sheets("Source")
LastLig = .Columns(1).Find("").Row
'on verifie que la donnée n'existe pas
x = Me.TextBox1
Set C = .Columns(1).Cells.Find(x)
If Not C Is Nothing Then
MsgBox "Donnée existe déjà!", vbCritical
Unload Me
Else
'on enregistre
.Cells(LastLig, 1) = UCase(Me.TextBox1.Text)
.Cells(LastLig, 2) = UCase(Trim(Me.TextBox2.Text)) '***comment supprimer les espaces
End If
End With
With Sheets("Cible")
Dim txt As String
LastLig = .Columns(1).Find("").Row
txt = Me.TextBox2.Text
x = LastLig
For i = 0 To UBound(Split(txt, "-"))
.Cells(x, "A") = Me.TextBox1
.Cells(x, "B") = Trim(Split(txt, "-")(i))
x = x + 1
Next i
End With
MsgBox "Enregistrement terminé!", vbExclamation
End Sub