Re : Aide bon de commande
bonjour Kim
une proposition d'après ce que j'ai compris
Sub CAduMois()
Dim LaDate As Range, MonMois As Byte, L As Long
MonMois = InputBox("Mois en chiffre - Janvier=1, Février=2, etc.)")
If MonMois < 1 And MonMois > 12 Then Exit Sub
Range("A1") = Choose(MonMois, "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aaût", "Septembre", "Octobre", "Novembre", "Décembre")
Range("A4:T42").Select ' A4:T42 est la zone de cellules recevant les données dans feuille CA_du_Mois
Selection.ClearContents
Range("A2").Select
With Worksheets("LISTING")
.Range("B3:B" & .Range("B5000").End(xlUp).Row).NumberFormat = "m"
Set LaDate = .Columns(2).Find(MonMois, LookIn:=xlValues)
If Not LaDate Is Nothing Then
firstAddress = LaDate.Address
Do
L = Range("B5000").End(xlUp).Row + 1
li = LaDate.Row
Cells(L, 1) = .Cells(li, 1)
Cells(L, 2) = .Cells(li, 2): Cells(L, 2).NumberFormat = "dd/mm/yyyy"
Cells(L, 3) = .Cells(li, 3)
Cells(L, 4) = .Cells(li, 4)
Cells(L, 5) = .Cells(li, 5): Cells(L, 5).NumberFormat = "dd/mm/yyyy"
Cells(L, 6) = .Cells(li, 6): Cells(L, 5).NumberFormat = "hh:mm"
Cells(L, 7) = .Cells(li, 7)
Cells(L, 8) = .Cells(li, 8)
Cells(L, 9).Formula = "=K" & L & "+M" & L & "+O" & L & "+Q" & L & "+S" & L
Cells(L, 10).Formula = "=L" & L & "+N" & L & "+P" & L & "+R" & L & "+T" & L
Cells(L, 11) = .Cells(li, 11)
Cells(L, 12) = CDbl(.Cells(li, 12))
Cells(L, 13) = .Cells(li, 14)
Cells(L, 14) = .Cells(li, 15)
Cells(L, 15) = .Cells(li, 17)
Cells(L, 16) = .Cells(li, 18)
Cells(L, 17) = .Cells(li, 20)
Cells(L, 18) = .Cells(li, 21)
Cells(L, 19) = .Cells(li, 23)
Cells(L, 20) = .Cells(li, 24)
Cells(L, 21) = .Cells(li, 26)
Cells(L, 22) = .Cells(li, 27)
Cells(L, 23) = .Cells(li, 29)
Cells(L, 24) = .Cells(li, 30)
Cells(L, 25) = .Cells(li, 32)
Cells(L, 26) = .Cells(li, 33)
Cells(L, 27) = .Cells(li, 35)
Cells(L, 28) = .Cells(li, 36)
Cells(L, 29) = .Cells(li, 38)
Cells(L, 30) = .Cells(li, 39)
Set LaDate = .Columns(2).FindNext(LaDate)
Loop While Not LaDate Is Nothing And LaDate.Address <> firstAddress
' Cells(44 + MonMois, 18) = Range("C46") ' D44 inconnu ... D46 cellule Total du Mois dans feuille CA_d_Mois ... D50 inconnu
' If Range("D46") <> Range("D50") Then MsgBox ("Attention, tu as dû oublier de saisir des codes produits, il en manque dans le total!")
End If
.Range("B3:B" & .Range("B5000").End(xlUp).Row).NumberFormat = "dd/mm/yyyy"
End With
End Sub
à bientôt