Classement colonnes

Bonsoir a tous,

j'ai plusieurs colonnes avec des donnees et je souhaiterais classer ces colonnes de la plus petite a la plus grande

je vous joint un exemple du resultat souhaites et vous remercie de votre support

7classement.xlsx (12.77 Ko)

Bonjour,

Sub ClassementCol()
    Dim Col(), k%, kk%, n%, i%
    With ActiveSheet
        kk = .Cells(1, .Columns.Count).End(xlToLeft).Column
        ReDim Col(kk, 1)
        For k = 1 To kk
            Col(k, 0) = k: Col(k, 1) = .Cells(.Rows.Count, k).End(xlUp).Row
        Next k
        For k = 1 To kk - 1
            For n = k + 1 To kk
                If Col(n, 1) < Col(k, 1) Then
                    For i = 0 To 1
                        Col(0, i) = Col(n, i): Col(n, i) = Col(k, i): Col(k, i) = Col(0, i)
                    Next i
                ElseIf Col(n, 1) = Col(k, 1) And Col(n, 0) < Col(k, 0) Then
                    Col(0, 0) = Col(n, 0): Col(n, 0) = Col(k, 0): Col(k, 0) = Col(0, 0)
                End If
            Next n
        Next k
        Application.ScreenUpdating = False
        For k = 1 To kk
            .Cells(1, kk + k).Resize(Col(k, 1)).Value = .Cells(1, Col(k, 0)) _
             .Resize(Col(k, 1)).Value
        Next k
        .Range("A1").Resize(, kk).EntireColumn.Delete
    End With
End Sub

Macro dans Module1.

Cordialement.

Bonjour MFerrand,

c 'est parfait comme d'habitude avec toi a chaque probleme une solution.

Merci Encore de ton aide pour toutes la communité de ce forum

Bonne jourrnée

Rechercher des sujets similaires à "classement colonnes"