Groupe ligne avec calcul

Bonjour,

Vous trouverez sur la pièce jointe une image qui illustre le résultat que je souhaiterais.

Globalement je souhaiterais ajouter dans une colonne une facon de grouper mes commandes en fonction du nombre de palette que cela represente.

Par exemple si une commande = 1,5 palette je voudrais regarder dans la liste pour ajouter une commande qui ferait moins de 0,5 palette.

Est-ce que vous auriez une idée de la façon dont je peux faire ca ?

Merci

excelgroup

bonjour,

une solution via une macro

Sub aargh()
    With Sheets(1)
        dl = .Cells(Rows.Count, 1).End(xlUp).Row
        .Rows("1:" & dl).Sort key1:=.Range("B1"), order1:=xlDescending, Header:=xlYes
        .Columns(4).Insert shift:=xlToRight
        For i = 2 To dl
            If .Cells(i, 2) < 1 Then k = i: Exit For
        Next i
        gr = 64
        For i = 2 To dl
            If .Cells(i, 3) = "" Then
                gr = gr + 1
                .Cells(i, 3) = Chr(gr)
                .Cells(i, 4) = .Cells(i, 4) + .Cells(i, 2)
                s = 1 - (.Cells(i, 4) - Int(.Cells(i, 4)))
                If s <> 0 Then
                    For j = k To dl
                        If .Cells(j, 3) = "" Then
                            If .Cells(j, 2) <= s Then
                                .Cells(j, 3) = .Cells(i, 3)
                                .Cells(i, 4) = .Cells(i, 4) + .Cells(j, 2)
                                s = s - .Cells(j, 2)
                                If s = 0 Then Exit For
                            End If
                        End If
                    Next j
                End If
            End If
        Next i
        .Columns(4).Delete shift:=xlToLeft
        .Rows("1:" & dl).Sort key1:=.Range("C1"), order1:=xlAscending, Header:=xlYes
    End With
End Sub
Rechercher des sujets similaires à "groupe ligne calcul"