Excel - VBA Copier et trier des colonnes

Bonjour,

Dans un fichier Excel, j'ai trois onglets :

Un onglet "Données sources"

Un onglet "Param"

  • Colonne A : la liste des participants
    Colonne B : le numéro de l'atelier
    Colonne C : la date de l'atelier
    Colonne D : l'heure de l'atelier (format 00:00)

Un onglet "Par intervenants"

Dans l'onglet "données sources", je saisie les dates, participants, les lieux... et via VBA je renseigne plusieurs autres onglets (plusieurs autres onglets non détaillés ici) dont l'onglet "Par participants". Dans cet onglet, je rapatrie les données sources et les réorganise par participants (numéro de l'ateliers, dates, heures,...) à partir de la cellule B2 (pour "données sources" et "par intervenants")

J'utilise actuellement la macro suivante qui me fait le tri par intervenant :

Sub Listing()

Sheets("Param").Select

Lfin1 = Cells(1, "A").End(xlDown).Row

Cfin1 = 1

tab1 = Range(Cells(2, "A"), Cells(Lfin1, Cfin1)).Value

Lfin1 = Lfin1 - 1

Sheets("Données sources").Select

Lfin4 = Cells(2, "B").End(xlDown).Row

Cfin4 = Cells(2, "B").End(xlToRight).Column

tab4 = Range(Cells(3, "B"), Cells(Lfin4, Cfin4)).Value

Lfin4 = Lfin4 - 2

tot1 = 2

Sheets("Par intervenants").Select

'par intervenants

For i = 1 To Lfin1

For j = 1 To Lfin4

If tab1(i, 1) = tab4(j, 10) Then

tot2 = tot2 + 1

For w = 1 To Cfin4 - 1

Cells(tot2, w + 1) = tab4(j, w)

Next w

End If

Next j

Next i

For i = tot2 + 2 To 600

For w = 1 To Cfin4 - 1

Cells(tot2 + 1, w + 1) = ""

Next w

Next i

tot3 = 2

Je souhaiterai que ce tri soit fait sur plusieurs échelons : par intervenant, puis par date, puis par heure. Et je sèche...

Si quelqu'un à une idée?

Bonjour. Bienvenue sur le Forum

Pour nous éviter d'avoir à construire un fichier, envoies s'il te plait le tien, ou un fichier exemple.

Cordialement

Voilà

Merci d'avance

J'ai trouvé une solution barbare mais qui fonctionne

Je rajoute un Excel run avec la macro suivante

Sub Trier_inter()

'

'

Application.ScreenUpdating = False

'

Range("B2:K600").Select

ActiveWorkbook.Worksheets("Par intervenants").Sort.SortFields.Clear

ActiveWorkbook.Worksheets("Par intervenants").Sort.SortFields.Add Key:=Range( _

"K3:K600"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _

xlSortNormal

ActiveWorkbook.Worksheets("Par intervenants").Sort.SortFields.Add Key:=Range( _

"G3:G600"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _

xlSortNormal

ActiveWorkbook.Worksheets("Par intervenants").Sort.SortFields.Add Key:=Range( _

"H3:H600"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _

xlSortNormal

With ActiveWorkbook.Worksheets("Par intervenants").Sort

.SetRange Range("B2:K600")

.Header = xlYes

.MatchCase = False

.Orientation = xlTopToBottom

.SortMethod = xlPinYin

.Apply

End With

End Sub

Merci

Rechercher des sujets similaires à "vba copier trier colonnes"