Lors de la validation copier sur 2 feuilles

S

sev

Guest
Bonsoir, je voudrais pouvoir aussi copier les valeurs d'un Userform sur 2 feuilles en même temps nommées "saisie" et " controle".
Je joint le code du bouton de validation; je choisirais ensuite les éléments à intégrer dans la feuille " controle".

Merci pour votre aide



Private Sub CommandButton1_Click()

If TextBox4 = "" Then MsgBox ("Entrer une somme"): End
If ComboBox4 = 0 Then MsgBox ("Entrer un type"): End
Dim LASTLIG As Integer
LASTLIG = Sheets("saisie").Range("A65536").End(xlUp).Row + 1
With Sheets("saisie")
Rem .Range("D" & LASTLIG) = ComboBox4
.Range("A" & LASTLIG) = TextBox1
.Range("B" & LASTLIG) = TextBox2
.Range("C" & LASTLIG) = TextBox3
.Range("F" & LASTLIG) = ListBox2
.Range("G" & LASTLIG) = ListBox3
.Range("E" & LASTLIG) = ListBox4

.Range("H" & LASTLIG) = TextBox8
.Range("I" & LASTLIG) = ComboBox4
.Range("O" & LASTLIG) = ComboBox3

If CheckBox1 = True Then .Range("L" & LASTLIG) = "R"
If CheckBox2 = True Then .Range("D" & LASTLIG) = TextBox + " " + TextBox6: TextBox6 = TextBox6 + 1
If CheckBox3 = True Then .Range("D" & LASTLIG) = TextBox + " " + TextBox7: TextBox7 = TextBox7 + 1
If ComboBox4 = "Crédit" Then .Range("J" & LASTLIG) = "c" Else .Range("J" & LASTLIG) = "d"
If ComboBox4 = "Crédit" Then .Range("M" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "CB" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "Chèque" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "Distributeur" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "Prélèvement" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "T.I.P" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "Espèces" Then .Range("K" & LASTLIG) = TextBox4.Value / 100



If ListBox3 = "Vidange" Then .Range("R4").Value = TextBox10.Value

If ListBox3 = "Gas Oil" Then .Range("P" & LASTLIG) = TextBox9 / 100
If ListBox3 = "Gas Oil" Then .Range("R" & LASTLIG).Value = TextBox10 - TextBox11
If ListBox3 = "Gas Oil" Then .Range("Q" & LASTLIG) = TextBox10
If ListBox3 = "Gas Oil" Then .Range("R6").Value = TextBox10.Value
If ListBox3 = "Gas Oil" Then .Range("V" & LASTLIG) = (TextBox9) / (TextBox10 - TextBox11)
If ListBox3 = "Gas Oil" Then .Range("W" & LASTLIG) = (TextBox4 / 100) / (TextBox10 - TextBox11)
If ListBox3 = "Gas Oil" Then .Range("S" & LASTLIG) = TextBox4 / TextBox9

If ListBox3 = "Essence" Then .Range("P" & LASTLIG) = TextBox9 / 100
If ListBox3 = "Essence" Then .Range("U" & LASTLIG).Value = TextBox10 - TextBox12
If ListBox3 = "Essence" Then .Range("T" & LASTLIG) = TextBox10
If ListBox3 = "Essence" Then .Range("T6").Value = TextBox10.Value
If ListBox3 = "Essence" Then .Range("V" & LASTLIG) = (TextBox9) / (TextBox10 - TextBox12)
If ListBox3 = "Essence" Then .Range("W" & LASTLIG) = (TextBox4 / 100) / (TextBox10 - TextBox11)
If ListBox3 = "Essence" Then .Range("S" & LASTLIG) = TextBox4 / TextBox9

'
'


End With

TextBox4.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
TextBox10.Value = ""
TextBox11.Value = ""
TextBox12.Value = ""
TextBox3.SetFocus



End Sub
 

skoobi

XLDnaute Barbatruc
Re : Lors de la validation copier sur 2 feuilles

Bonsoir,
A tester avec les modifications en rouge:

Code:
Private Sub CommandButton1_Click()
[COLOR="Red"]Dim feuille As Worksheet[/COLOR]
If TextBox4 = "" Then MsgBox ("Entrer une somme"): End
If ComboBox4 = 0 Then MsgBox ("Entrer un type"): End
Dim LASTLIG As Integer
LASTLIG = Sheets("saisie").Range("A65536").End(xlUp).Row + 1
[COLOR="Red"]For Each feuille In Sheets[/COLOR]
[COLOR="Red"]If feuille.Name = "saisie" Or feuille.Name = "controle" Then[/COLOR]
With [COLOR="Red"]feuille[/COLOR]
Rem .Range("D" & LASTLIG) = ComboBox4
.Range("A" & LASTLIG) = TextBox1
.Range("B" & LASTLIG) = TextBox2
.Range("C" & LASTLIG) = TextBox3
.Range("F" & LASTLIG) = ListBox2
.Range("G" & LASTLIG) = ListBox3
.Range("E" & LASTLIG) = ListBox4

.Range("H" & LASTLIG) = TextBox8
.Range("I" & LASTLIG) = ComboBox4
.Range("O" & LASTLIG) = ComboBox3

If CheckBox1 = True Then .Range("L" & LASTLIG) = "R"
If CheckBox2 = True Then .Range("D" & LASTLIG) = TextBox + " " + TextBox6: TextBox6 = TextBox6 + 1
If CheckBox3 = True Then .Range("D" & LASTLIG) = TextBox + " " + TextBox7: TextBox7 = TextBox7 + 1
If ComboBox4 = "Crédit" Then .Range("J" & LASTLIG) = "c" Else .Range("J" & LASTLIG) = "d"
If ComboBox4 = "Crédit" Then .Range("M" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "CB" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "Chèque" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "Distributeur" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "Prélèvement" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "T.I.P" Then .Range("K" & LASTLIG) = TextBox4.Value / 100
If ComboBox4 = "Espèces" Then .Range("K" & LASTLIG) = TextBox4.Value / 100



If ListBox3 = "Vidange" Then .Range("R4").Value = TextBox10.Value

If ListBox3 = "Gas Oil" Then .Range("P" & LASTLIG) = TextBox9 / 100
If ListBox3 = "Gas Oil" Then .Range("R" & LASTLIG).Value = TextBox10 - TextBox11
If ListBox3 = "Gas Oil" Then .Range("Q" & LASTLIG) = TextBox10
If ListBox3 = "Gas Oil" Then .Range("R6").Value = TextBox10.Value
If ListBox3 = "Gas Oil" Then .Range("V" & LASTLIG) = (TextBox9) / (TextBox10 - TextBox11)
If ListBox3 = "Gas Oil" Then .Range("W" & LASTLIG) = (TextBox4 / 100) / (TextBox10 - TextBox11)
If ListBox3 = "Gas Oil" Then .Range("S" & LASTLIG) = TextBox4 / TextBox9

If ListBox3 = "Essence" Then .Range("P" & LASTLIG) = TextBox9 / 100
If ListBox3 = "Essence" Then .Range("U" & LASTLIG).Value = TextBox10 - TextBox12
If ListBox3 = "Essence" Then .Range("T" & LASTLIG) = TextBox10
If ListBox3 = "Essence" Then .Range("T6").Value = TextBox10.Value
If ListBox3 = "Essence" Then .Range("V" & LASTLIG) = (TextBox9) / (TextBox10 - TextBox12)
If ListBox3 = "Essence" Then .Range("W" & LASTLIG) = (TextBox4 / 100) / (TextBox10 - TextBox11)
If ListBox3 = "Essence" Then .Range("S" & LASTLIG) = TextBox4 / TextBox9

'
'

[COLOR="Red"]
End With
End If[/COLOR]
[COLOR="Red"]Next[/COLOR]

TextBox4.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
TextBox10.Value = ""
TextBox11.Value = ""
TextBox12.Value = ""
TextBox3.SetFocus



End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 304
Messages
2 087 062
Membres
103 449
dernier inscrit
pulco41