Option Explicit
Private Sub CommandButton1_Click()
Dim i, y, k As Integer
Dim iDerLigne, nbLigne, nbVide As Integer
iDerLigne = [A65000].End(xlUp).Row
nbVide = Application.CountIf(Range("A4:A" & iDerLigne), "")
nbLigne = 1
k = TextBox37.Value
If nbVide > 0 Then
For i = 4 To iDerLigne
If Cells(i, 1) = "" And nbLigne <= k Then
Cells(i, 1) = (TextBox1)
Cells(i, 2) = (TextBox2)
Cells(i, 3) = (TextBox3)
Cells(i, 4) = (TextBox38)
Cells(i, 5) = (TextBox33)
Cells(i, 6) = (TextBox34)
Cells(i, 7) = (TextBox7)
nbLigne = nbLigne + 1
End If
Next
End If
If nbLigne < k Then
For i = nbLigne To k
y = Cells(Rows.Count, 2).End(xlUp).Row + 1
Cells(y, 1) = (TextBox1)
Cells(y, 2) = (TextBox2)
Cells(y, 3) = (TextBox3)
Cells(y, 4) = (TextBox38)
Cells(y, 5) = (TextBox33)
Cells(y, 6) = (TextBox34)
Cells(y, 7) = (TextBox7)
Next i
End If
Unload Me
End Sub