1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Option Explicit
Private Sub CommandButton1_Click()
Dim DLig As Long, NLig As Long
' Dernière Ligne remplie de la feuille data de la colonne B
DLig = Sheets("data").Range("B" & Rows.Count).End(xlUp).Row
'Emplacement de mes sources sur la feuille data
Me.ComboBox1.RowSource = "='data'!B2:B" & DLig
Me.ComboBox2.RowSource = "='data'!C2:C" & DLig
Me.ComboBox3.RowSource = "='data'!H2:H" & DLig
Me.ComboBox4.RowSource = "='data'!L2:L" & DLig
Me.ComboBox5.RowSource = "='data'!K2:K" & DLig
With Sheets("Activités")
NLig = .Range("B1202").End(xlUp).Row + 1
'colonne de destination des données saisies dans le USF
.Cells(NLig, 2).Value = ComboBox1
.Cells(NLig, 4).Value = ComboBox2
.Cells(NLig, 9).Value = ComboBox2
.Cells(NLig, 11).Value = ComboBox2
.Cells(NLig, 12).Value = ComboBox2
.Cells(NLig, 3).Value = TextBox1
.Cells(NLig, 5).Value = TextBox2
.Cells(NLig, 6).Value = TextBox3
.Cells(NLig, 7).Value = TextBox4
.Cells(NLig, 8).Value = TextBox5
.Cells(NLig, 10).Value = TextBox6
.Cells(NLig, 12).Value = TextBox7
.Cells(NLig, 13).Value = TextBox8
End With
MsgBox "Créer une nouvelle demande", vbInformation + vbYesNo, "Nouvelle demande"
If vbYes Then
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.ComboBox3.Value = ""
Me.ComboBox4.Value = ""
Me.ComboBox5.Value = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox6.Value = ""
Me.TextBox7.Value = ""
Me.TextBox8.Value = ""
ComboBox1.SetFocus
Else
UserForm7.Hide
End If
End Sub |
Partager