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
| Private Sub UserForm_Initialize()
Dim nbmois As Byte, i As Byte
nbmois = Feuil2.Cells(1, 1).End(xlDown).Row
If ComboBox1.ListCount <> nbmois Then
ComboBox1.Clear
For i = 1 To nbmois
ComboBox1.AddItem (Feuil2.Cells(i, 1))
Next i
Else
End If
End Sub
'Bouton Valider
Private Sub Valider_Click()
Dim nbmois As Integer, i As Integer, xVerif As Integer, derniereligne As Integer, valTarget As Integer, j As Integer
derniereligne = Feuil1.Cells(Rows.Count, 3).End(xlUp).Row
nbmois = Feuil2.Cells(1, 1).End(xlDown).Row
xVerif = 1
For i = 1 To nbmois
If ComboBox1.Value = Feuil2.Cells(i, 1) Then
valTarget = i
Else
End If
Next i
For i = 1 To derniereligne
If Feuil1.Cells(i, 3) = "Total" Then
If xVerif = valTarget Then
Feuil1.Rows(i - 1).Insert (xlShiftDown)
Feuil1.Cells(i - 1, 3) = TextBox1.Value & " " & Left(TextBox2, 1)
Feuil1.Cells(i - 1, 4) = TextBox3.Value
Feuil1.Cells(i - 1, 5) = TextBox4.Value
Feuil1.Cells(i - 1, 6) = TextBox5.Value
Feuil1.Cells(i - 1, 7) = TextBox6.Value
Exit For
Else
xVerif = xVerif + 1
End If
Else
End If
Next i
Unload Me
End Sub |
Partager