IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Problème de temps de réponse en utilisant la fonction "Sort"


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Novembre 2018
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2018
    Messages : 2
    Par défaut Problème de temps de réponse en utilisant la fonction "Sort"
    Bjr
    J'ai une feuille Excel connecté avec une base de données d'un ERP (AX). Après avoir extraits les données je lance plusieurs macro dont une pour trier ces données... La même feuille de calcul est utilisée pour extraire des données de pays différent... Sur un pays l’exécution du tri dure max 4" et sur un autre pays 1'30 ! Il y a plus de lignes sur le premier pays, et je ne m'explique pas le problème... Est ce que quelqu'un aurait une idée ? Le tri comporte 5 colonnes , 1 date, 1 zone concaténer, et 3 zones textes...

  2. #2
    Membre Expert Avatar de mfoxy
    Homme Profil pro
    Automation VBA
    Inscrit en
    Février 2018
    Messages
    752
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Automation VBA
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Février 2018
    Messages : 752
    Par défaut
    Bonjour sans voir ton code pas simple de t aider
    Cependant je vois cellule concatenate dans ton descriptif, donc formule
    Chaque champs, celule à ce formules est donc recalculer lors de l exécution de ta macro

    Tu pourrais peut être encadré ton code par


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    Application.ScreenUpdating = False
    Application.Calculation = xlManual
     
     ' ton code de traitement 
     
    Application.ScreenUpdating = True
    Application.Calculation = xlAutomatic

  3. #3
    Nouveau candidat au Club
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Novembre 2018
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Chef de projet NTIC
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2018
    Messages : 2
    Par défaut Suite
    Bonjour et merci pour cette réponse

    J'avais bien dans mon code le passage en mode manuel et auto avant et après le tri, j'ai ajouté le ScreenUpdating, mais sans résultat
    Voila mon code, c'est assez simple, les colonnes sont nommés

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
        Application.ScreenUpdating = False
        Application.Calculation = xlManual
     
        Application.Run "Sort"
     
        Application.ScreenUpdating = True
        Application.Calculation = xlAutomatic
     
    Sub Sort()
    '
    Sheets("AX").Select
     
        Range("Ax_BIC_ProdJobCard_E[[#Headers],[Production]]").Select
        Range(Selection, Selection.End(xlToRight)).Select
        ActiveWorkbook.Worksheets("AX").ListObjects("Ax_BIC_ProdJobCard_E").Sort. _
            SortFields.Clear
        ActiveWorkbook.Worksheets("AX").ListObjects("Ax_BIC_ProdJobCard_E").Sort. _
            SortFields.Add Key:=Range("Ax_BIC_ProdJobCard_E[Free2]"), SortOn:= _
            xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("AX").ListObjects("Ax_BIC_ProdJobCard_E").Sort. _
            SortFields.Add Key:=Range("Ax_BIC_ProdJobCard_E[Free1]"), SortOn:= _
            xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("AX").ListObjects("Ax_BIC_ProdJobCard_E").Sort. _
            SortFields.Add Key:=Range("Ax_BIC_ProdJobCard_E[Delivery]"), SortOn:= _
            xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("AX").ListObjects("Ax_BIC_ProdJobCard_E").Sort. _
            SortFields.Add Key:=Range("Ax_BIC_ProdJobCard_E[Production]"), SortOn:= _
            xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
         ActiveWorkbook.Worksheets("AX").ListObjects("Ax_BIC_ProdJobCard_E").Sort. _
            SortFields.Add Key:=Range("Ax_BIC_ProdJobCard_E[Production.Oper. No.]"), SortOn:= _
            xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("AX").ListObjects("Ax_BIC_ProdJobCard_E").Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    '
    End Sub

  4. #4
    Membre Expert Avatar de mfoxy
    Homme Profil pro
    Automation VBA
    Inscrit en
    Février 2018
    Messages
    752
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : Belgique

    Informations professionnelles :
    Activité : Automation VBA
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Février 2018
    Messages : 752
    Par défaut edit
    hello,

    Pourriez-vous publier un excel avec donnée bidons pour test svp

    edit :
    je viens de tester sur 30000 lignes et jusque colonne AB en effectuant tris AZ sur 12 colonnes moins de 1.5 seconde

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
     
    Sub Macro1()
    '
    ' Macro1 Macro
    Application.ScreenUpdating = False
    Application.Calculation = xlManual
    '
    Dim DerLig As Long
    Dim ws As Worksheet
     
    Set ws = Sheets("Sheet1") ' modifier nom feuille Sheet1
    DerLig = ActiveWorkbook.Worksheets(ws.Name).Cells(Rows.Count, 1).End(xlUp).Row
     
        With ActiveWorkbook.Worksheets(ws.Name).Sort
     
             .SortFields.Clear
     
             .SortFields.Add Key:=Range("A2:A" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("B2:B" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("C2:C" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("D2:D" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("E2:E" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("F2:F" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("G2:G" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("H2:H" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("I2:I" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("J2:J" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("K2:K" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
             .SortFields.Add Key:=Range("L2:L" & DerLig), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
     
             .SetRange Range("A2:AB" & DerLig)
             .Header = xlGuess
             .MatchCase = False
             .Orientation = xlTopToBottom
             .SortMethod = xlPinYin
             .Apply
     
        End With
     
    Application.ScreenUpdating = True
    Application.Calculation = xlAutomatic
     
    End Sub

Discussions similaires

  1. [Débutant] Problème de temps de réponse pour une recherche d'articles
    Par Tazze-99 dans le forum VB.NET
    Réponses: 22
    Dernier message: 14/12/2011, 10h50
  2. Problème de temps de réponse ASP.NET
    Par fredlang dans le forum ASP.NET
    Réponses: 0
    Dernier message: 12/07/2011, 10h23
  3. Réponses: 1
    Dernier message: 05/01/2011, 15h23
  4. Problème de temps de réponse Dédoublonnage
    Par ALEXM dans le forum Access
    Réponses: 12
    Dernier message: 19/06/2007, 17h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo