Private Sub CmdPrélèvementImp_Click()
Dim Control As Object
Dim Mois As Boolean
Dim i As Byte, j As Byte, k As Byte
Dim ligne As Byte, lignelistbox As Byte
Dim derligne As Integer
Dim present As Boolean
Dim presentnumero As Boolean
Dim tablosplit
Mois = False
For Each Control In Données.FrameSélectMois.Controls
If Control.Value = True Then Mois = True: Exit For
Next
If Not Mois Then
MsgBox "Sélectionnez un mois !", vbExclamation, G & " / Opération impossible"
Exit Sub
End If
If ComboDateImp.Value = "" Then
MsgBox "Select. Mois-Année.", vbExclamation, G & " / Opération impossible"
ComboDateImp.SetFocus
Exit Sub
End If
'
''Code pour Imp ?
'O3.Range("A1") = ComboDateImp.Value
'Unload Données
O3.Range("a3:d10000").ClearContents
For i = 0 To ListBox1.ListCount - 1
present = False
For j = 3 To O3.Range("a65536").End(xlUp).Row
If O3.Cells(j, 1) & CStr(O3.Cells(j, 3)) = ListBox1.List(i, 0) & ListBox1.List(i, 2) Then
ligne = j: lignelistbox = i
present = True
End If
Next j
If present = True Then
presentnumero = False
O3.Cells(ligne, 4) = O3.Cells(ligne, 4) + CDbl(ListBox1.List(lignelistbox, 3))
tablosplit = Split(O3.Cells(ligne, 2), "_")
For k = 0 To UBound(tablosplit)
If tablosplit(k) = ListBox1.List(lignelistbox, 1) Then
presentnumero = True
End If
Next k
If Not presentnumero Then
O3.Cells(ligne, 2) = O3.Cells(ligne, 2) & "_" & ListBox1.List(lignelistbox, 1)
End If
Else
derligne = O3.Range("a65536").End(xlUp).Row + 1
O3.Cells(derligne, 1) = ListBox1.List(i, 0)
O3.Cells(derligne, 2) = ListBox1.List(i, 1)
O3.Cells(derligne, 3) = CDate(ListBox1.List(i, 2))
O3.Cells(derligne, 4) = CDbl(ListBox1.List(i, 3))
End If
Next i
End Sub