VBA Copier et trier avec multicritères
Résolu/Fermé
Arnaud4181
Messages postés
4
Date d'inscription
mardi 16 octobre 2012
Statut
Membre
Dernière intervention
16 octobre 2012
-
16 oct. 2012 à 16:45
Arnaud4181 Messages postés 4 Date d'inscription mardi 16 octobre 2012 Statut Membre Dernière intervention 16 octobre 2012 - 16 oct. 2012 à 17:45
Arnaud4181 Messages postés 4 Date d'inscription mardi 16 octobre 2012 Statut Membre Dernière intervention 16 octobre 2012 - 16 oct. 2012 à 17:45
A voir également:
- VBA Copier et trier avec multicritères
- Copier une vidéo youtube - Guide
- Super copier - Télécharger - Gestion de fichiers
- Excel trier par ordre croissant chiffre - Guide
- Copier texte pdf - Guide
- Copier disque dur - Guide
4 réponses
Arnaud4181
Messages postés
4
Date d'inscription
mardi 16 octobre 2012
Statut
Membre
Dernière intervention
16 octobre 2012
16 oct. 2012 à 16:46
16 oct. 2012 à 16:46
J'aurai bien ajouté un fichier exemple mais je ne sais pas comment...
michel_m
Messages postés
16603
Date d'inscription
lundi 12 septembre 2005
Statut
Contributeur
Dernière intervention
16 décembre 2023
3 303
Modifié par michel_m le 16/10/2012 à 16:57
Modifié par michel_m le 16/10/2012 à 16:57
bonjour,
pour joindre une pièce
mettre le classeur sans données confidentielles en pièce jointe sur
https://www.cjoint.com/
puis copier l'adresse du lien et la coller dans le message de réponse
idée sans avoir piocher ton code:
pour le tri sur 3 colonnes, essaies par l'enregistreur de macro et "traduit" en VBA
autres asrtuces
pour le confort visuel et la rapidité (gain: +/- 80x)
en début de code
application.screenupdating=false
(pas la peine de le remettre à True en fin de macro)
et évite le select à remplacer par (par ex)
attention: ne pas oublier les points devant "range" et "cells"
pour joindre une pièce
mettre le classeur sans données confidentielles en pièce jointe sur
https://www.cjoint.com/
puis copier l'adresse du lien et la coller dans le message de réponse
idée sans avoir piocher ton code:
pour le tri sur 3 colonnes, essaies par l'enregistreur de macro et "traduit" en VBA
autres asrtuces
pour le confort visuel et la rapidité (gain: +/- 80x)
en début de code
application.screenupdating=false
(pas la peine de le remettre à True en fin de macro)
et évite le select à remplacer par (par ex)
With Sheets("Données sources") 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 end with
attention: ne pas oublier les points devant "range" et "cells"
Arnaud4181
Messages postés
4
Date d'inscription
mardi 16 octobre 2012
Statut
Membre
Dernière intervention
16 octobre 2012
16 oct. 2012 à 17:07
16 oct. 2012 à 17:07
Voilà le lien pour le fichier
https://www.cjoint.com/?BJqrdf6aGra
https://www.cjoint.com/?BJqrdf6aGra
Arnaud4181
Messages postés
4
Date d'inscription
mardi 16 octobre 2012
Statut
Membre
Dernière intervention
16 octobre 2012
16 oct. 2012 à 17:45
16 oct. 2012 à 17:45
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
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