Option Explicit
Private WS1 As Worksheet
Private WS2 As Worksheet
Const G As String = "MISE A JOUR"
Private Sub ComboBox1_Change()
Dim lig As Integer
If ComboBox1.ListIndex < 0 Then Exit Sub
lig = ComboBox1.ListIndex + 2
TextBox1.Value = WS1.Cells(lig, 2).Value
End Sub
Private Sub Label2_Click()
End Sub
Private Sub UserForm_Initialize()
Dim Lf_données As Long
Dim DerLg, i
Set WS1 = ThisWorkbook.Worksheets("Feuil3")
Set WS2 = ThisWorkbook.Worksheets("Feuil2")
Lf_données = WS1.Range("A65536").End(xlUp).Row
DerLg = WS1.Range("A2200").End(xlToLeft).Row
With WS1
For i = 2 To DerLg
ComboBox1.AddItem .Cells(i, 1)
Next i
End With
ComboBox1.Value = ""
Me.Caption = G
ComboBox4.Visible = False
Label5.Visible = False
End Sub
Private Sub valider_Click()
Application.ScreenUpdating = False
'Déclaration de variable 'L' pour connaitre le numéro de la Ligne
Dim L As Integer
'ici je repère la dernière ligne vide pour coller les données
L = Sheets("Feuil2").Range("A65536").End(xlUp).Row + 1
'Ici c'est le report de la saisie dans la feuille
L = ComboBox1.ListIndex + 2
With Sheets("Feuil2")
.Cells(L, 1).Value = Me.TextBox6.Value
.Cells(L, 2).Value = Me.TextBox1.Value
.Cells(L, 3).Value = Me.ComboBox2.Value
.Cells(L, 4).Value = Me.ComboBox3.Value
.Cells(L, 5).Value = Me.ComboBox4.Value
.Cells(L, 6).Value = Me.ComboBox5.Value
.Cells(L, 7).Value = Me.TextBox2.Value
.Cells(L, 8).Value = Me.TextBox3.Value
.Cells(L, 9).Value = Me.ComboBox6.Value
.Cells(L, 15).Value = Me.ComboBox7.Value
.Cells(L, 16).Value = Me.TextBox4.Value
.Cells(L, 17).Value = Me.ComboBox8.Value
.Cells(L, 18).Value = Me.TextBox5.Value
.Cells(L, 10).Value = DTPicker1.Value
.Cells(L, 13).Value = DTPicker3.Value
End With
Application.ScreenUpdating = True
End Sub
Private Sub ComboBox3_Change()
If ComboBox3.Value = "SOR" Then MsgBox " Merci d'indiquer le nom de la campagne concernée "
If ComboBox3.Value = "SOR" Then ComboBox4.Visible = True
If ComboBox3.Value = "SOR" Then Label5.Visible = True
If ComboBox3.Value <> "SOR" Then Label5.Visible = False
If ComboBox3.Value <> "SOR" Then ComboBox4.Visible = False
End Sub
Private Sub CommandButton1_Click() 'Valider
Dim DerLigne As Integer, i As Byte
DerLigne = Range("Feuil2!A20000").End(xlUp).Row
Sheets("Feuil2").Cells(DerLigne + 1, 1) = DerLigne
TextBox6.Value = DerLigne
End Sub