Copier coller feuille
q
Bonjour , lorsque je ne me trouve pas sur la feuille ou tout ce copie , cela ne marche pas pourquoi ?
Cordialement
Private Sub CommandButton1_Click()
Dim L As Integer
If MsgBox("Confirmez-vous l'insertion de ces produit ?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then
L = Sheets("losfeld").Range("a65536").End(xlUp).Row + 1 '
Range("A" & L).Value = TextBox1.Text
Range("A" & L + 1).Value = TextBox2.Text
Range("A" & L + 2).Value = TextBox3.Text
Range("A" & L + 3).Value = TextBox4.Text
Range("A" & L + 4).Value = TextBox5.Text
Range("A" & L + 5).Value = TextBox6.Text
Range("A" & L + 6).Value = TextBox7.Text
Range("A" & L + 7).Value = TextBox8.Text
Range("A" & L + 8).Value = TextBox9.Text
Range("A" & L + 9).Value = TextBox10.Text
Range("B" & L).Value = TextBox11.Text
Range("B" & L + 1).Value = TextBox12.Text
Range("B" & L + 2).Value = TextBox13.Text
Range("B" & L + 3).Value = TextBox14.Text
Range("B" & L + 4).Value = TextBox15.Text
Range("B" & L + 5).Value = TextBox16.Text
Range("B" & L + 6).Value = TextBox17.Text
Range("B" & L + 7).Value = TextBox18.Text
Range("B" & L + 8).Value = TextBox19.Text
Range("B" & L + 9).Value = TextBox20.Text
Range("C" & L).Value = TextBox21.Text
Range("C" & L + 1).Value = TextBox22.Text
Range("C" & L + 2).Value = TextBox23.Text
Range("C" & L + 3).Value = TextBox24.Text
Range("C" & L + 4).Value = TextBox25.Text
Range("C" & L + 5).Value = TextBox26.Text
Range("C" & L + 6).Value = TextBox27.Text
Range("C" & L + 7).Value = TextBox28.Text
Range("C" & L + 8).Value = TextBox29.Text
Range("C" & L + 9).Value = TextBox30.Text
Range("D" & L).Value = TextBox31.Text
Range("D" & L + 1).Value = TextBox32.Text
Range("D" & L + 2).Value = TextBox33.Text
Range("D" & L + 3).Value = TextBox34.Text
Range("D" & L + 4).Value = TextBox35.Text
Range("D" & L + 5).Value = TextBox36.Text
Range("D" & L + 6).Value = TextBox37.Text
Range("D" & L + 7).Value = TextBox38.Text
Range("D" & L + 8).Value = TextBox39.Text
Range("D" & L + 9).Value = TextBox40.Text
End If
Unload LOSFELD
End Sub
Private Sub CommandButton2_Click()
Unload LOSFELD
End Sub
C
Bonjour,
Parce que Range fait référence à la feuille active. Remplaces (code non testé car pas de fichier joint)
L = Sheets("losfeld").Range("a65536").End(xlUp).Row + 1 '
Range("A" & L).Value = TextBox1.Text
Range("A" & L + 1).Value = TextBox2.Text
par
With Sheets("losfeld") '
L = .Range("a65536").End(xlUp).Row + 1
' Ou mieux car indépendant de la version d'Excel
L = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
.Range("A" & L).Value = TextBox1.Text
.Range("A" & L + 1).Value = TextBox2.Text
' etc
End With
q
salut a toi , malheureusement ca ne marche pas , j'aurai du joindre le fichier de base..
B
Hello,
Essaie ça mais je n'ai pas testé
Private Sub CommandButton1_Click()
Dim L As Integer
If MsgBox("Confirmez-vous l'insertion de ces produit ?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then
L = Sheets("losfeld").Range("A" & Rows.Count).End(xlUp).Row + 1 '
For i = 0 to 9
Range("A" & L + i) = Controls("TextBox" & i+1)
Next i
For i = 0 to 9
Range("B" & L + i) = Controls("TextBox" & i+11)
Next i
For i = 0 to 9
Range("C" & L + i) = Controls("TextBox" & i+21)
Next i
For i = 0 to 9
Range("D" & L + i) = Controls("TextBox" & i+31)
Next i
End If
Unload LOSFELD
End Sub
Private Sub CommandButton2_Click()
Unload LOSFELD
End Sub
@+
C
Bonjour,
Voir fichier ci-joint. J'ai repris ce que je t'avais envoyé, ça fonctionne que tu sois ou non sur la feuille "losfeld" et j'y ai intégré l'optimisation de BAROUTE78.
Attention : en faisant un test initial avec ton code, j'ai probablement "pourri" la feuille "Feuil2".