XL 2010 Résolu par la communauté : Tri bcp trop long

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour toutes et à tous,

Comme dirait mon cher Marcel, je suis toujours sur mon "chef d'œuvre" de fichier <LOL
D'ailleurs, je rectifie car en fait c'est votre "chef d'œuvre" à toutes et tous.
Et je n'ai pas de "Merci" assez gros pour vous en remercier :)

Mon fichier est plutôt gros, environ 2 mégas et plus de 20.000 lignes bientôt avec une dizaine de formules plutôt longues par ligne (donc plus de 200.000 formules).
Exemple :
Code:
=SI(L1="Bientôt";CONCATENER(AN5;" ";"               à traiter");
SI(L1="Rappels ";CONCATENER(AM5;" ";"               à traiter");
SI(L1="OK";CONCATENER(AL5;" ";"               à traiter");
SI(L1="URGENTS";CONCATENER(AK5;" ";"               à traiter");
SI(L1="ROKR";CONCATENER(AJ5;" ";"               à traiter");
SI(L1="toutbon";CONCATENER(AG5;" ";"               à traiter");
CONCATENER($AF$5-AI5;" ";"               à traiter")))))))

J'ai un gros souci de tris qui sont très longs (plus d'une minute).
Et, pour nos sélections, nous trions tout le temps.

Voici un aperçu de l'un d'entres eux :
Code:
Sub DatesRappelsOKRdV()
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Application.Calculation = xlManual
    Sheets("SuivisAppels").Select
 
    If [y5] = "oubli" Then
     Call Blocage
    Exit Sub
    End If
 
    ActiveSheet.Unprotect Password:=""
    Range("E3").Select
    ActiveCell.FormulaR1C1 = 1
 
    Rows("7:20000").Select
    Selection.EntireRow.Hidden = False
    Dim I As Long
    For I = 7 To Cells(Rows.Count, 33).End(xlUp).Row '7 = n° ligne - 33 = n° col
    Rows(I).Hidden = Not Cells(I, 33) = Range("E3") 'n° client "à faire"
    Range("l1").Select
    ActiveCell.FormulaR1C1 = "Rappels URGENTS OK RdV"
    Next I
 
    Range("E3").Select
    ActiveCell.FormulaR1C1 = "OK RdV - Rappelez vite"
    '1er tri ordre n° clients
    Rows("7:20000").Select
    ActiveWorkbook.Worksheets("SuivisAppels").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("SuivisAppels").Sort.SortFields.Add Key:=Range("t7:t20000"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("SuivisAppels").Sort
        .SetRange Range("A7:BZ20000")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
 
    '2e3e tri ordre dates
    Rows("7:20000").Select
    ActiveWorkbook.Worksheets("SuivisAppels").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("SuivisAppels").Sort.SortFields.Add Key:=Range("ag7:ag20000") _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("SuivisAppels").Sort
        .SetRange Range("A7:BBZ20000")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveSheet.EnableSelection = xlNoRestrictions
    Call Remonte
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Application.Calculation = xlAutomatic
End Sub

je cherche une solution que je ne trouve pas.

Si quelqu'un a une idée, ce serait super ;)
Ne pouvant pas reproduite le souci sur un "petit" fichier test, je ne peux pas joindre de fichier.

Espérant être clair (ce qui ne semble pas être mon point fort LOL),
Je reste à écoute.

Avec mes remerciements, je vous souhaite, à toutes et à tous, un bon dimanche.
Amicalement,
Lionel,
 

Si...

XLDnaute Barbatruc
Bonjour

pour ne pas rester Hors … Sujet ni Hors ... Service ;)


Le bouton étant sur la feuille, autant écrire sa macro associée dans la fenêtre de codes de celle-ci et la référence With devient inutile !

On peut avoir un seul bouton pour les 2 tris selon la colonne H avec

VB:
Dim n As Byte
Sub Macro1()
  n = IIf(n = 1, 2, 1) '1 pour XlAsending, 2 pour xlDescending
  Range("A12:H" & [A65000].End(xlUp).Row).Sort [H12], n
End Sub

Nota : on peut aussi adapter le texte du bouton en fonction de l’ordre et on a aussi cela avec un bouton bascule (ToggleButton)
VB:
Private Sub ToggleButton1_Click()
  Dim n As Byte ‘si Option Explicit présent
  n = IIf(ToggleButton1, 2, 1)
   ToggleButton1.Caption = IIf(n = 1, "Descendant", "Ascendant")
  Range("A12:H" & [A65000].End(xlUp).Row).Sort [H12], n
End Sub
 

Pièces jointes

  • tri(s).xlsm
    26.9 KB · Affichages: 34

Discussions similaires

Réponses
3
Affichages
567
Réponses
11
Affichages
418

Statistiques des forums

Discussions
312 076
Messages
2 085 086
Membres
102 773
dernier inscrit
dorok