Bonjour,
J'ai saisi cette fonction qui permet d'ajouter une ligne dans le tableau client, ensuite j'ai créer un bouton pour lancer cette fonction avec la commande call, mais quand je clic sur ce bouton rien ne se passe.
La fonction :
Function copy_from_form_without_repeat_Ref()
Dim LastRowValue As Long
LastRowValue = ActiveWorkbook.Sheets("Client").Range("A1000000").End(xlUp).Value
TextBox1 = LastRowValue + 1
Dim rng1 As Range
Dim str_search As String
str_search = TextBox1.Value
ActiveWorkbook.Sheets("Client").Activate
Set rng1 = Sheets("Client").Range("B:B").Find(str_search, , xlValues, xlWhole)
If rng1 Is Nothing Then
Dim LastRow As Long
LastRow = ActiveWorkbook.Sheets("Client").Range("A1000000").End(xlUp).Row
LastRow = LastRow + 1
With ActiveWorkbook.Sheets("Client")
.Range("A" & LastRow).Value = TextBox1.Value
.Range("B" & LastRow).Value = TextBox2.Value
.Range("C" & LastRow).Value = TextBox3.Value
.Range("D" & LastRow).Value = TextBox4.Value
.Range("E" & LastRow).Value = TextBox5.Value
.Range("F" & LastRow).Value = TextBox6.Value
.Range("G" & LastRow).Value = TextBox7.Value
End With
Else
MsgBox str_search & " is Found"
End If
End Function
la commande du bouton :
Private Sub BtnAjouter_Click()
Call copy_from_form_without_repeat_Ref
End Sub