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 :

Script VBA - dépassement de capacité [XL-2016]


Sujet :

Macros et VBA Excel

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    contrôleur gestion
    Inscrit en
    Septembre 2014
    Messages
    55
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : contrôleur gestion

    Informations forums :
    Inscription : Septembre 2014
    Messages : 55
    Points : 29
    Points
    29
    Par défaut Script VBA - dépassement de capacité
    Bonjour à tous,

    Je voulais vous remercier pour l'aide précieuse que vous m'avez apporté dans tous les aspects d'utilisation d'Excel.
    Je suis confronté à un nouveau problème et ma connaissance embryonnaire du script VBA ne me permet pas de débloquer la situation.
    Je dispose d'une macro (boucle) qui fait très bien son travail . Elle indique toutes les dates ( une date par cellule) entre la date de début et la date de fin.
    Malheureusement arrivé à la ligne 32768 de mon classeur Excel , un message d'erreur apparaît: Erreur d'exécution '6' Dépassement de capacité

    Y a t'il un moyen de contourner le problème
    Je vous remercie
    Morgan
    Images attachées Images attachées  

  2. #2
    Membre confirmé Avatar de Nain porte koi
    Homme Profil pro
    peu importe
    Inscrit en
    Novembre 2023
    Messages
    375
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : peu importe

    Informations forums :
    Inscription : Novembre 2023
    Messages : 375
    Points : 594
    Points
    594
    Par défaut
    Hello,

    sans voir le code c'est toujours hypothétique... donc vous devez utilisez une variable de type Integer donc limité à des nombres entiers compris entre -32 768 et 32 767
    https://learn.microsoft.com/fr-fr/of...eger-data-type

    Le type Long devrait vous convenir de -2 147 483 648 à 2 147 483 647 (faut pas que ça dépasse 2 milliards et des brouettes de lignes )
    plus d'info sur les types de variables ici https://learn.microsoft.com/fr-fr/of...a-type-summary
    JièL
    Membre des AMIS
    Anti Macro Inutilement Superfétatoire

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    contrôleur gestion
    Inscrit en
    Septembre 2014
    Messages
    55
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine et Marne (Île de France)

    Informations professionnelles :
    Activité : contrôleur gestion

    Informations forums :
    Inscription : Septembre 2014
    Messages : 55
    Points : 29
    Points
    29
    Par défaut
    Bonjour Nain porte koi,

    Je te remercie pour l'information.
    En requalifiant la variable en long, le script se déroule normalement

  4. #4
    Futur Membre du Club
    Homme Profil pro
    Responsable de projet fonctionnel
    Inscrit en
    Août 2024
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Responsable de projet fonctionnel

    Informations forums :
    Inscription : Août 2024
    Messages : 5
    Points : 7
    Points
    7
    Par défaut même problème mais avec LONG j'ai d'autres problèmes..
    bonjour Nain porte quoi

    je me permets de te déranger en direct
    je suis bac moins 10 en excel et j'ai repris le boulot d'un mec qui est parti et qui était médaille d'or en macro excel...
    seulement ses supers macros plantent et je galère sévère !!

    j'ai le même problème que la personne

    voici le code

    Dim MatriceEngage() As Variant, MatriceRealise() As Variant
    'Identification du Dossier de stockage
    import = Application.GetOpenFilename("Tous les Fichiers(*.*), *.*", , "Importation des Fichiers")
    'Isoler l'adresse du dossier de stockage
    Dos = CurDir(import)
    'Vérifier nombre de fichier du Dossier
    NombreFichier = NombreFichiers(Dos)
    'Changement du répertoir par défaut
    ChDir Dos
    MonFichier = Dir("*.*")
    While MonFichier <> ""
    Set Classeur = Workbooks.Open(MonFichier)
    TypeClasseur = Identification(Classeur)
    If TypeClasseur = "Engagé" Then
    MatriceEngage() = Classeur.Worksheets(1).Cells(1, 1).CurrentRegion.Value
    ElseIf TypeClasseur = "Réalisé" Then
    MatriceRealise() = Classeur.Worksheets(1).Cells(1, 1).CurrentRegion.Value
    End If
    Classeur.Close (False)
    Set Classeur = Nothing
    MonFichier = Dir()
    Wend
    'On obtient 2 matrices en mémoire cache
    'on créé une 3ème matrice qui correspond au fichier actuel (avant suppression)
    Dim MatriceSuiviBudget() As Variant
    MatriceSuiviBudget() = ThisWorkbook.Worksheets("Détail").Cells(1, 1).CurrentRegion.Value
    'on supprime les information budgétaire
    Application.ScreenUpdating = False
    With ThisWorkbook.Worksheets("Détail")
    .Range(.Cells(2, 1), .Cells(UBound(MatriceSuiviBudget, 1), UBound(MatriceSuiviBudget, 2))).Clear

    'On engage l'enregistrement des informations
    'On commence par les commandes réceptionnées
    Dim ColReaPeriode As Integer, ColReaTexteCommande As Integer, ColReaDescriptionNatureComptable As Integer, ColReaValeur As Integer
    Dim ColReaDate As Integer, ColReaOTP As Integer, ColReaDocumentAchat As Integer, ColReaDesignation As Integer, ColReaQuantite As Integer
    Dim ColReaArticle As Integer, ColReaNatureComptable As Integer, ColReaPosteCommande As Integer, ColReaDateComptable As Integer
    Dim ColReaDateSaisi As Integer, ColReaUtilisateur As Integer, ColReaTextePiece As Integer, ColReaUniteQuantite As Integer, ColReaPieceRef As Integer

    ColReaPeriode = ColonneCible_Matrice(MatriceRealise, "Période", 1)
    ColReaTexteCommande = ColonneCible_Matrice(MatriceRealise, "Texte de la commande d'achat", 1)
    ColReaDescriptionNatureComptable = ColonneCible_Matrice(MatriceRealise, "Descr.nat.comptable", 1)
    ColReaValeur = ColonneCible_Matrice(MatriceRealise, "Val./dev.état", 1)
    ColReaDate = ColonneCible_Matrice(MatriceRealise, "Date de la pièce", 1)
    ColReaOTP = ColonneCible_Matrice(MatriceRealise, "Elément d'OTP", 1)
    ColReaDocumentAchat = ColonneCible_Matrice(MatriceRealise, "Document d'achat", 1)
    ColReaDesignation = ColonneCible_Matrice(MatriceRealise, "Désignation", 1)
    ColReaQuantite = ColonneCible_Matrice(MatriceRealise, "Quantité totale", 1)
    ColReaUniteQuantite = ColonneCible_Matrice(MatriceRealise, "Unité de quantité", 1)
    ColReaArticle = ColonneCible_Matrice(MatriceRealise, "Article", 1)
    ColReaNatureComptable = ColonneCible_Matrice(MatriceRealise, "Nature comptable", 1)
    ColReaPosteCommande = ColonneCible_Matrice(MatriceRealise, "Poste Commande", 1)
    ColReaDateComptable = ColonneCible_Matrice(MatriceRealise, "Date comptable", 1)
    ColReaDateSaisi = ColonneCible_Matrice(MatriceRealise, "Date de saisie", 1)
    ColReaUtilisateur = ColonneCible_Matrice(MatriceRealise, "Utilisateur", 1)
    ColReaTextePiece = ColonneCible_Matrice(MatriceRealise, "Texte d'en-tête de pièce", 1)
    ColReaPieceRef = ColonneCible_Matrice(MatriceRealise, "Nº pièce référence", 1)

    Dim i As Integer, j As Integer, k As Integer, m As Integer
    Dim CommandeEnregistre As Boolean
    CommandeEnregistre = False

    Dim QuantiteReceptionnee() As Variant
    ReDim QuantiteReceptionnee(UBound(MatriceRealise, 1), 4)
    QuantiteReceptionnee(1, 1) = "Commande"
    QuantiteReceptionnee(1, 2) = "Poste"
    QuantiteReceptionnee(1, 3) = "Quantite"
    QuantiteReceptionnee(1, 4) = "CommandeTrouvee"

    j = 2
    k = 1
    For i = 2 To UBound(MatriceRealise, 1)
    'Nécessaire de revoir le code car les quantités reçu sont inclus uniquement dans les classes 8
    'on va créer une matrice sépcifique lié uniquement aux quantité
    If Left(MatriceRealise(i, ColReaNatureComptable), 1) <> 8 Then
    'on exclut les nature comptable de classe 8 pour les commandes réalisées
    .Cells(j, ColType) = "Réalisé"
    .Cells(j, ColDocumentAchat) = MatriceRealise(i, ColReaDocumentAchat)
    .Cells(j, ColPoste) = MatriceRealise(i, ColReaPosteCommande)
    .Cells(j, ColArticle) = MatriceRealise(i, ColReaArticle)
    .Cells(j, ColTexteCommande) = MatriceRealise(i, ColReaTexteCommande)
    .Cells(j, ColDesignation) = MatriceRealise(i, ColReaDesignation)
    .Cells(j, ColQuantite) = MatriceRealise(i, ColReaQuantite)
    .Cells(j, ColUniteQuantite) = MatriceRealise(i, ColReaUniteQuantite)
    .Cells(j, ColValeur) = MatriceRealise(i, ColReaValeur)
    .Cells(j, ColOTP) = MatriceRealise(i, ColReaOTP)
    .Cells(j, ColNatureComptable) = MatriceRealise(i, ColReaNatureComptable)
    .Cells(j, ColDescriptionNatureComptable) = MatriceRealise(i, ColReaDescriptionNatureComptable)
    .Cells(j, ColDateComptable) = MatriceRealise(i, ColReaDateComptable)
    .Cells(j, ColPeriode) = MatriceRealise(i, ColReaPeriode)
    .Cells(j, ColDatePiece) = MatriceRealise(i, ColReaDate)
    .Cells(j, ColUtilisateur) = MatriceRealise(i, ColReaUtilisateur)
    .Cells(j, ColTexteEnTete) = MatriceRealise(i, ColReaTextePiece)
    .Cells(j, ColPieceRef) = MatriceRealise(i, ColReaPieceRef)
    j = j + 1
    ElseIf Left(MatriceRealise(i, ColReaNatureComptable), 1) = 8 Then
    For m = 1 To k
    If StrComp(MatriceRealise(i, ColReaDocumentAchat) & MatriceRealise(i, ColReaPosteCommande), QuantiteReceptionnee(m, 1) & QuantiteReceptionnee(m, 2), vbTextCompare) = 0 And _
    MatriceRealise(i, ColReaDocumentAchat) <> "" Then
    QuantiteReceptionnee(m, 3) = QuantiteReceptionnee(m, 3) + MatriceRealise(i, ColReaQuantite)
    CommandeEnregistre = True
    Exit For
    End If
    Next m
    If CommandeEnregistre = False And MatriceRealise(i, ColReaDocumentAchat) <> "" Then
    QuantiteReceptionnee(k + 1, 1) = MatriceRealise(i, ColReaDocumentAchat)
    QuantiteReceptionnee(k + 1, 2) = MatriceRealise(i, ColReaPosteCommande)
    QuantiteReceptionnee(k + 1, 3) = MatriceRealise(i, ColReaQuantite)
    QuantiteReceptionnee(k + 1, 4) = False
    k = k + 1
    End If
    CommandeEnregistre = False
    End If
    Next i



    Dim Derligne As Variant
    Derligne = .Cells(Rows.Count, 1).End(xlUp).Row
    For i = 2 To Derligne
    If .Cells(i, ColArticle) <> "" Then
    j = 2
    Do Until QuantiteReceptionnee(j, 1) = ""
    If StrComp(.Cells(i, ColDocumentAchat) & .Cells(i, ColPoste), QuantiteReceptionnee(j, 1) & QuantiteReceptionnee(j, 2), vbTextCompare) = 0 And _
    QuantiteReceptionnee(j, 4) = False Then
    .Cells(i, ColQuantite) = QuantiteReceptionnee(j, 3)
    QuantiteReceptionnee(j, 4) = True
    Exit Do
    End If
    j = j + 1
    Loop
    End If
    Next i
    Erase QuantiteReceptionnee

    'On poursuit avec les engagements
    Dim ColEngType As Integer, ColEngDate As Integer, ColEngNatureComptable As Integer, ColEngValeur As Integer, ColEngQuantite As Integer
    Dim ColEngUniteQuantite As Integer, ColEngOTP As Integer, ColEngDesignation As Integer, ColEngDocumentAchat As Integer, ColEngPoste As Integer
    Dim ColEngArticle As Integer, ColEngDescriptionNatureComptable As Integer, ColEngPeriode As Integer, ColEngSuppression As Integer


    ColEngType = ColonneCible_Matrice(MatriceEngage, "Catégorie de la pièce de référence", 1)
    ColEngDate = ColonneCible_Matrice(MatriceEngage, "Date chargement", 1)
    ColEngNatureComptable = ColonneCible_Matrice(MatriceEngage, "Nature comptable", 1)
    ColEngValeur = ColonneCible_Matrice(MatriceEngage, "Val./devise périm.", 1)
    ColEngQuantite = ColonneCible_Matrice(MatriceEngage, "Quantité totale", 1)
    ColEngUniteQuantite = ColonneCible_Matrice(MatriceEngage, "Unité de quantité", 1)
    ColEngOTP = ColonneCible_Matrice(MatriceEngage, "Elément d'OTP", 1)
    ColEngDesignation = ColonneCible_Matrice(MatriceEngage, "Désignation", 1)
    ColEngDocumentAchat = ColonneCible_Matrice(MatriceEngage, "Nº pièce référence", 1)
    ColEngPoste = ColonneCible_Matrice(MatriceEngage, "Poste de réf.", 1)
    ColEngArticle = ColonneCible_Matrice(MatriceEngage, "Article", 1)
    ColEngDescriptionNatureComptable = ColonneCible_Matrice(MatriceEngage, "Désign.nat.comptable", 1)
    ColEngPeriode = ColonneCible_Matrice(MatriceEngage, "Période", 1)
    ColEngSuppression = ColonneCible_Matrice(MatriceEngage, "Code de suppression", 1)


    Derligne = .Cells(Rows.Count, 1).End(xlUp).Row
    For j = 2 To Derligne
    If .Cells(j, 1) = "" Then
    Exit For
    End If
    Next

    For i = 2 To UBound(MatriceEngage, 1)

    et la matrice plante quand elle arrive à la ligne Ubound...
    les matrices sont en Variant

    si tu sais m'aider je t'en serais à toujours reconnaissant !

    et voici les détails sur ce que fait la macro...

    o Sans rentrer dans le détail, la macro enregistre en mémoire l’ensemble des informations présentes dans l’onglet détail avant de supprimer intégralement les informations inscrites. A partir des fichiers Excel exportés précédemment, la macro inscrit les mouvements comptables à l’exception des Commandes réceptionnées de nature comptable 8 et des commandes engagés ou DA dont la valeur est nulle. La macro ajoute les informations complémentaires liées au chapitre lorsqu’elle parvient à les recouper.

    NB

  5. #5
    Membre chevronné
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    1 335
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 335
    Points : 1 948
    Points
    1 948
    Par défaut
    Salut,

    Il y a un bouton a utiliser pour poster tes codes sources (celui qui ressemble à #).
    Ce sera autrement plus lisible, et on sera plus enclin à t'apporter une réponse.

  6. #6
    Futur Membre du Club
    Homme Profil pro
    Responsable de projet fonctionnel
    Inscrit en
    Août 2024
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Responsable de projet fonctionnel

    Informations forums :
    Inscription : Août 2024
    Messages : 5
    Points : 7
    Points
    7
    Par défaut
    Bonjour

    j'ai mis tout le début du code.
    J'espère que ça pourra vous aider à m'aider ;-)

    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
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
     
    Sub Main()
    'Définition de la structure du fichier
    Dim ColDateMAJ As Integer
    ColDateMAJ = ColonneCible(ThisWorkbook.Name, "Détail", "Date mise à jour", 1)
    ThisWorkbook.Worksheets("Détail").Cells(2, ColDateMAJ) = Date
     
    Dim ColType As Integer, ColDocumentAchat As Integer, ColPoste As Integer, ColArticle As Integer, ColTexteCommande As Integer
    Dim ColDesignation As Integer, ColQuantite As Integer, ColUniteQuantite As Integer, ColValeur As Integer, ColOTP As Integer
    Dim ColNatureComptable As Integer, ColDescriptionNatureComptable As Integer, ColDateComptable As Integer, ColPeriode As Integer
    Dim ColDatePiece As Integer, ColUtilisateur As Integer, ColTexteEnTete As Integer, ColCommentaire As Integer, ColChapitre As Integer
    Dim ColPieceRef As Integer
     
     
    ColType = ColonneCible(ThisWorkbook.Name, "Détail", "Type", 1)
    ColDocumentAchat = ColonneCible(ThisWorkbook.Name, "Détail", "Document d'achat", 1)
    ColPoste = ColonneCible(ThisWorkbook.Name, "Détail", "Poste", 1)
    ColArticle = ColonneCible(ThisWorkbook.Name, "Détail", "Article", 1)
    ColTexteCommande = ColonneCible(ThisWorkbook.Name, "Détail", "Texte de la commande d'achat", 1)
    ColDesignation = ColonneCible(ThisWorkbook.Name, "Détail", "Désignation", 1)
    ColQuantite = ColonneCible(ThisWorkbook.Name, "Détail", "Quantité totale", 1)
    ColUniteQuantite = ColonneCible(ThisWorkbook.Name, "Détail", "Unité de quantité", 1)
    ColValeur = ColonneCible(ThisWorkbook.Name, "Détail", "Valeur", 1)
    ColOTP = ColonneCible(ThisWorkbook.Name, "Détail", "Elément d'OTP", 1)
    ColNatureComptable = ColonneCible(ThisWorkbook.Name, "Détail", "Nature comptable", 1)
    ColDescriptionNatureComptable = ColonneCible(ThisWorkbook.Name, "Détail", "Descr.nat.comptable", 1)
    ColDateComptable = ColonneCible(ThisWorkbook.Name, "Détail", "Date comptable", 1)
    ColPeriode = ColonneCible(ThisWorkbook.Name, "Détail", "Période", 1)
    ColDatePiece = ColonneCible(ThisWorkbook.Name, "Détail", "Date de la pièce", 1)
    ColUtilisateur = ColonneCible(ThisWorkbook.Name, "Détail", "Utilisateur", 1)
    ColTexteEnTete = ColonneCible(ThisWorkbook.Name, "Détail", "Texte d'en-tête de pièce", 1)
    ColCommentaire = ColonneCible(ThisWorkbook.Name, "Détail", "Commentaires", 1)
    ColChapitre = ColonneCible(ThisWorkbook.Name, "Détail", "Chapitre", 1)
    ColPieceRef = ColonneCible(ThisWorkbook.Name, "Détail", "N° Pièce référénces", 1)
     
    Dim import As String, Dos As String, NombreFichier As Integer, MonFichier As String, TypeClasseur As String
    Dim MatriceEngage() As Variant, MatriceRealise() As Variant
    'Identification du Dossier de stockage
    import = Application.GetOpenFilename("Tous les Fichiers(*.*), *.*", , "Importation des Fichiers")
    'Isoler l'adresse du dossier de stockage
    Dos = CurDir(import)
    'Vérifier nombre de fichier du Dossier
    NombreFichier = NombreFichiers(Dos)
    'Changement du répertoir par défaut
    ChDir Dos
    MonFichier = Dir("*.*")
    While MonFichier <> ""
        Set Classeur = Workbooks.Open(MonFichier)
        TypeClasseur = Identification(Classeur)
        If TypeClasseur = "Engagé" Then
            MatriceEngage() = Classeur.Worksheets(1).Cells(1, 1).CurrentRegion.Value
        ElseIf TypeClasseur = "Réalisé" Then
            MatriceRealise() = Classeur.Worksheets(1).Cells(1, 1).CurrentRegion.Value
        End If
        Classeur.Close (False)
        Set Classeur = Nothing
        MonFichier = Dir()
    Wend
    'On obtient 2 matrices en mémoire cache
    'on créé une 3ème matrice qui correspond au fichier actuel (avant suppression)
    Dim MatriceSuiviBudget() As Variant
    MatriceSuiviBudget() = ThisWorkbook.Worksheets("Détail").Cells(1, 1).CurrentRegion.Value
    'on supprime les information budgétaire
    Application.ScreenUpdating = False
    With ThisWorkbook.Worksheets("Détail")
        .Range(.Cells(2, 1), .Cells(UBound(MatriceSuiviBudget, 1), UBound(MatriceSuiviBudget, 2))).Clear
     
        'On engage l'enregistrement des informations
        'On commence par les commandes réceptionnées
        Dim ColReaPeriode As Integer, ColReaTexteCommande As Integer, ColReaDescriptionNatureComptable As Integer, ColReaValeur As Integer
        Dim ColReaDate As Integer, ColReaOTP As Integer, ColReaDocumentAchat As Integer, ColReaDesignation As Integer, ColReaQuantite As Integer
        Dim ColReaArticle As Integer, ColReaNatureComptable As Integer, ColReaPosteCommande As Integer, ColReaDateComptable As Integer
        Dim ColReaDateSaisi As Integer, ColReaUtilisateur As Integer, ColReaTextePiece As Integer, ColReaUniteQuantite As Integer, ColReaPieceRef As Integer
     
        ColReaPeriode = ColonneCible_Matrice(MatriceRealise, "Période", 1)
        ColReaTexteCommande = ColonneCible_Matrice(MatriceRealise, "Texte de la commande d'achat", 1)
        ColReaDescriptionNatureComptable = ColonneCible_Matrice(MatriceRealise, "Descr.nat.comptable", 1)
        ColReaValeur = ColonneCible_Matrice(MatriceRealise, "Val./dev.état", 1)
        ColReaDate = ColonneCible_Matrice(MatriceRealise, "Date de la pièce", 1)
        ColReaOTP = ColonneCible_Matrice(MatriceRealise, "Elément d'OTP", 1)
        ColReaDocumentAchat = ColonneCible_Matrice(MatriceRealise, "Document d'achat", 1)
        ColReaDesignation = ColonneCible_Matrice(MatriceRealise, "Désignation", 1)
        ColReaQuantite = ColonneCible_Matrice(MatriceRealise, "Quantité totale", 1)
        ColReaUniteQuantite = ColonneCible_Matrice(MatriceRealise, "Unité de quantité", 1)
        ColReaArticle = ColonneCible_Matrice(MatriceRealise, "Article", 1)
        ColReaNatureComptable = ColonneCible_Matrice(MatriceRealise, "Nature comptable", 1)
        ColReaPosteCommande = ColonneCible_Matrice(MatriceRealise, "Poste Commande", 1)
        ColReaDateComptable = ColonneCible_Matrice(MatriceRealise, "Date comptable", 1)
        ColReaDateSaisi = ColonneCible_Matrice(MatriceRealise, "Date de saisie", 1)
        ColReaUtilisateur = ColonneCible_Matrice(MatriceRealise, "Utilisateur", 1)
        ColReaTextePiece = ColonneCible_Matrice(MatriceRealise, "Texte d'en-tête de pièce", 1)
        ColReaPieceRef = ColonneCible_Matrice(MatriceRealise, "Nº pièce référence", 1)
     
        Dim i As Integer, j As Integer, k As Integer, m As Integer
        Dim CommandeEnregistre As Boolean
        CommandeEnregistre = False
     
        Dim QuantiteReceptionnee() As Variant
        ReDim QuantiteReceptionnee(UBound(MatriceRealise, 1), 4)
        QuantiteReceptionnee(1, 1) = "Commande"
        QuantiteReceptionnee(1, 2) = "Poste"
        QuantiteReceptionnee(1, 3) = "Quantite"
        QuantiteReceptionnee(1, 4) = "CommandeTrouvee"
     
        j = 2
        k = 1
        For i = 2 To UBound(MatriceRealise, 1)
            'Nécessaire de revoir le code car les quantités reçu sont inclus uniquement dans les classes 8
            'on va créer une matrice sépcifique lié uniquement aux quantité
            If Left(MatriceRealise(i, ColReaNatureComptable), 1) <> 8 Then
                'on exclut les nature comptable de classe 8 pour les commandes réalisées
                .Cells(j, ColType) = "Réalisé"
                .Cells(j, ColDocumentAchat) = MatriceRealise(i, ColReaDocumentAchat)
                .Cells(j, ColPoste) = MatriceRealise(i, ColReaPosteCommande)
                .Cells(j, ColArticle) = MatriceRealise(i, ColReaArticle)
                .Cells(j, ColTexteCommande) = MatriceRealise(i, ColReaTexteCommande)
                .Cells(j, ColDesignation) = MatriceRealise(i, ColReaDesignation)
                .Cells(j, ColQuantite) = MatriceRealise(i, ColReaQuantite)
                .Cells(j, ColUniteQuantite) = MatriceRealise(i, ColReaUniteQuantite)
                .Cells(j, ColValeur) = MatriceRealise(i, ColReaValeur)
                .Cells(j, ColOTP) = MatriceRealise(i, ColReaOTP)
                .Cells(j, ColNatureComptable) = MatriceRealise(i, ColReaNatureComptable)
                .Cells(j, ColDescriptionNatureComptable) = MatriceRealise(i, ColReaDescriptionNatureComptable)
                .Cells(j, ColDateComptable) = MatriceRealise(i, ColReaDateComptable)
                .Cells(j, ColPeriode) = MatriceRealise(i, ColReaPeriode)
                .Cells(j, ColDatePiece) = MatriceRealise(i, ColReaDate)
                .Cells(j, ColUtilisateur) = MatriceRealise(i, ColReaUtilisateur)
                .Cells(j, ColTexteEnTete) = MatriceRealise(i, ColReaTextePiece)
                .Cells(j, ColPieceRef) = MatriceRealise(i, ColReaPieceRef)

    et lorsque la macro arrive à For i = 2 To UBound(MatriceRealise, 1) j'ai le message d'erreur "dépassement de capacité"

  7. #7
    Expert éminent

    Homme Profil pro
    Curieux
    Inscrit en
    Juillet 2012
    Messages
    5 125
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Curieux
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Juillet 2012
    Messages : 5 125
    Points : 9 953
    Points
    9 953
    Billets dans le blog
    5
    Par défaut
    Bonjour,


    remplace tout tes "integer" par "long", notamment la variable i, car UBound(MatriceRealise, 1) doit probablement dépasser 32767 (c'est le nombre de lignes utilisées dans la feuille 1 de ton classeur)

  8. #8
    Futur Membre du Club
    Homme Profil pro
    Responsable de projet fonctionnel
    Inscrit en
    Août 2024
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Responsable de projet fonctionnel

    Informations forums :
    Inscription : Août 2024
    Messages : 5
    Points : 7
    Points
    7
    Par défaut
    j'avais bien pensé à faire ça mais j'avais pas osé.
    bon la macro plante encore mais elle a passé l'étape du Ubound.
    je recommencerai demain j'en ai ma claque
    en tout cas merci pour l'aide et je pense qu'on va se revoir souvent ;-)
    bonne soirée les gars et merci encore

  9. #9
    Membre chevronné
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    1 335
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 335
    Points : 1 948
    Points
    1 948
    Par défaut
    j'ai repris le boulot d'un mec qui est parti et qui était médaille d'or en macro excel...
    Mouais heu, médaille d'or, c'est ton point de vue …
    Du mien c'est plutôt médaille de 5 lettres bien odorante.
    - Noms peut parlants.
    - Grosse fonction "fourre-tout" en violation directe du SRP (https://fr.wikipedia.org/wiki/Princi...t%C3%A9_unique).
    - Gestion d'erreurs absente.
    (pour ne citer que cela).

    Si le projet n'est pas trop gros, Je pense qu'il serait utile de savoir ce que c'est censé faire, avoir un échantillon de données, histoire de repartir sur des bases saines
    (bref: faire une refonte).

  10. #10
    Membre confirmé Avatar de Nain porte koi
    Homme Profil pro
    peu importe
    Inscrit en
    Novembre 2023
    Messages
    375
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : peu importe

    Informations forums :
    Inscription : Novembre 2023
    Messages : 375
    Points : 594
    Points
    594
    Par défaut
    Hello GNINO

    pour info, normalement on ne s'adresse pas à une personne en particulier dans un forum, a moins que ce soit pour une suite d'un problème déjà évoqué avec la personne.
    La preuve, je n'étais pas là et d'autres (plus compétents que moi) t'on répondus, certainement mieux que je ne l'aurais fait
    JièL
    Membre des AMIS
    Anti Macro Inutilement Superfétatoire

  11. #11
    Futur Membre du Club
    Homme Profil pro
    Responsable de projet fonctionnel
    Inscrit en
    Août 2024
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Responsable de projet fonctionnel

    Informations forums :
    Inscription : Août 2024
    Messages : 5
    Points : 7
    Points
    7
    Par défaut
    Citation Envoyé par Nain porte koi Voir le message
    Hello GNINO

    pour info, normalement on ne s'adresse pas à une personne en particulier dans un forum, a moins que ce soit pour une suite d'un problème déjà évoqué avec la personne.
    La preuve, je n'étais pas là et d'autres (plus compétents que moi) t'on répondus, certainement mieux que je ne l'aurais fait
    t'as bien raison mais je n'ai jamais trouvé le bouton créer une nouvelle discussion
    je m'excuse de t'avoir dérangé en direct - après avec un pseudo aussi fun je me suis dit que tu ne pouvais qu'être un mec cool

  12. #12
    Futur Membre du Club
    Homme Profil pro
    Responsable de projet fonctionnel
    Inscrit en
    Août 2024
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Responsable de projet fonctionnel

    Informations forums :
    Inscription : Août 2024
    Messages : 5
    Points : 7
    Points
    7
    Par défaut
    Citation Envoyé par deedolith Voir le message
    Mouais heu, médaille d'or, c'est ton point de vue …
    Du mien c'est plutôt médaille de 5 lettres bien odorante.

    - Noms peut parlants.
    - Grosse fonction "fourre-tout" en violation directe du SRP (https://fr.wikipedia.org/wiki/Princi...t%C3%A9_unique).
    - Gestion d'erreurs absente.
    (pour ne citer que cela).

    Si le projet n'est pas trop gros, Je pense qu'il serait utile de savoir ce que c'est censé faire, avoir un échantillon de données, histoire de repartir sur des bases saines
    (bref: faire une refonte).

    mais alors là je suis chaud quand tu veux si t'as du temps pour m'aider. je paye en apéro liquide solide en bonne humeur et bagues graveuleuses.
    Quand il m'a présenté le mec m'a dit : si c'était à refaire je ferais pas comme ça ... sans blague

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. deboguage script VBA
    Par jojodid dans le forum VBA Access
    Réponses: 1
    Dernier message: 24/08/2008, 21h36
  2. Execution d'un script VBA depuis un lien HTML
    Par Mattius007 dans le forum VBA Outlook
    Réponses: 2
    Dernier message: 07/02/2008, 16h58
  3. Réponses: 2
    Dernier message: 08/03/2007, 10h50
  4. Transformé une formule Excel en script VBA ?
    Par SFLEY dans le forum Macros et VBA Excel
    Réponses: 14
    Dernier message: 06/01/2007, 11h48
  5. Script vba excel trop lent
    Par zootman dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 10/07/2006, 14h27

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