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 :

erreur 2015 dans boucle


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre Expert

    Homme Profil pro
    Technicien Métrologie R&D
    Inscrit en
    Janvier 2007
    Messages
    1 610
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien Métrologie R&D
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 610
    Billets dans le blog
    1
    Par défaut erreur 2015 dans boucle
    Bonjour
    je suis en cours de réalisation d'une macro qui doit être utilisé à la gestion d'appareil de stockage.
    le principe est le suivant
    un bouton appelle le mouvement (entree / sortie)
    un verrou est mit sur l'opération tant que la feuille de mouvement n'est pas sortie le type de mouvement est bloqué)
    le problème est en entré si mon stock n'est pas à zéro (quel que soit le stockeur comportant le stock ) la macro tourne
    si le stock est à zéro la macro me retourne une erreur 2015
    je joinds la macro en entier mais le système de balayage des stockeurs est quatre fois le même

    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
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    Sub ajout_plato(Qte_Cart, NbCartPlato, MotCle, Type_Cart, k)
    '***********************************************************
    '* Cas d'insuffisance de place  recherche de plateau libre *
    '***********************************************************
     
    Dim lg As Byte
    Dim fini As Byte
    Dim tablo() As Variant
    Dim Sortie_Tablo()
    Dim Stockeur As String
    Dim Plateau As String
     
    '____Ceci est dans la macro Zone_Nommee__appelee par "entré_en_stock"_____
    'With ActiveWorkbook.Names
    '        .Add Name:="StoKeRA", RefersTo:="=Donnees!$O$2:$O$" & StocRA
    '        .Add Name:="StoKeRB", RefersTo:="=Donnees!$P$2:$P$" & StocRB
    '        .Add Name:="StoKeRC", RefersTo:="=Donnees!$Q$2:$Q$" & StocRC
    '        .Add Name:="StoKeRD", RefersTo:="=Donnees!$R$2:$R$" & StocRD
    'End With
    '__et défini les quatre stockeurs A B C et D
    lg = Sheets("stock").Range("a65535").End(xlUp).Row + 1
    a = 0
    Sheets("Donnees").Select
    'Recherche des vides dans le stockeur A
    For Each cel In Range("StokeRA")
    If cel = 0 Then
    Plateau = Cells(cel.Row, 6).Value
    Stockeur = Cells(1, cel.Column).Value
    ReDim Preserve tablo(5, a)
    If Qte_Cart > NbCartPlato Then
        tablo(0, a) = lg
        tablo(1, a) = MotCle
        tablo(2, a) = NbCartPlato
        tablo(3, a) = Plateau
        tablo(4, a) = Stockeur
        tablo(5, a) = Type_Cart
        Qte_Cart = Qte_Cart - NbCartPlato
        a = a + 1
        lg = lg + 1
    Else
        tablo(0, a) = lg
        tablo(1, a) = MotCle
        tablo(2, a) = Qte_Cart
        tablo(3, a) = Cells(cel.Row, 6).Value
        tablo(4, a) = Cells(1, cel.Column).Value
        tablo(5, a) = Type_Cart
        Qte_Cart = 0
        a = a + 1
        lg = lg + 1
        fini = 1
    Exit For
    End If
    End If
    Next
    If fini = 0 Then
    'Recherche des vide dans la stockeur B
    For Each cel In Range("StokeRB")
    If cel = 0 Then
    Plateau = Cells(cel.Row, 6).Value
    Stockeur = Cells(1, cel.Column).Value
    ReDim Preserve tablo(5, a)
        If Qte_Cart > NbCartPlato Then
        tablo(0, a) = lg
        tablo(1, a) = MotCle
        tablo(2, a) = NbCartPlato
        tablo(3, a) = Plateau
        tablo(4, a) = Stockeur
        tablo(5, a) = Type_Cart
        Qte_Cart = Qte_Cart - NbCartPlato
        a = a + 1
        lg = lg + 1
    Else
        tablo(0, a) = lg
        tablo(1, a) = MotCle
        tablo(2, a) = Qte_Cart
        tablo(3, a) = Cells(cel.Row, 6).Value
        tablo(4, a) = Cells(1, cel.Column).Value
        tablo(5, a) = Type_Cart
        Qte_Cart = 0
        a = a + 1
        lg = lg + 1
        fini = 1
    Exit For
    End If
    End If
    Next
    If fini = 0 Then
    'Recherche des vide dans la stockeur C
    For Each cel In Range("StokeRC")
    If cel = 0 Then
    Plateau = Cells(cel.Row, 6).Value
    Stockeur = Cells(1, cel.Column).Value
    ReDim Preserve tablo(5, a)
    If Qte_Cart > NbCartPlato Then
        tablo(0, a) = lg
        tablo(1, a) = MotCle
        tablo(2, a) = NbCartPlato
        tablo(3, a) = Plateau
        tablo(4, a) = Stockeur
        tablo(5, a) = Type_Cart
        Qte_Cart = Qte_Cart - NbCartPlato
        a = a + 1
        lg = lg + 1
    Else
        tablo(0, a) = lg
        tablo(1, a) = MotCle
        tablo(2, a) = Qte_Cart
        tablo(3, a) = Cells(cel.Row, 6).Value
        tablo(4, a) = Cells(1, cel.Column).Value
        tablo(5, a) = Type_Cart
        Qte_Cart = 0
        a = a + 1
        lg = lg + 1
        fini = 1
    Exit For
    End If
    End If
    Next
    If fini = 0 Then
    'Recherche des vides dans la stockeur D
    For Each cel In Range("StokeRD")
    If cel = 0 Then
    Plateau = Cells(cel.Row, 6).Value
    Stockeur = Cells(1, cel.Column).Value
    ReDim Preserve tablo(5, a)
    If Qte_Cart > NbCartPlato Then
        tablo(0, a) = lg
        tablo(1, a) = MotCle
        tablo(2, a) = NbCartPlato
        tablo(3, a) = Plateau
        tablo(4, a) = Stockeur
        tablo(5, a) = Type_Cart
        Qte_Cart = Qte_Cart - NbCartPlato
        a = a + 1
        lg = lg + 1
    Else
        tablo(0, a) = lg
        tablo(1, a) = MotCle
        tablo(2, a) = Qte_Cart
        tablo(3, a) = Cells(cel.Row, 6).Value
        tablo(4, a) = Cells(1, cel.Column).Value
        tablo(5, a) = Type_Cart
        Qte_Cart = 0
        a = a + 1
        lg = lg + 1
        fini = 1
    Exit For
    End If
    End If
    Next
    End If
    End If
    End If
    a = a - 1 'annulation de la derniere incrementation
    ReDim Preserve Sortie_Tablo(a, 5)
    For t = 0 To a
    For j = 0 To 5
    Sortie_Tablo(t, j) = tablo(j, t)
    Next j
    Next t
    Sheets("mouvements").Select
    Range("k" & k & ":p" & k + a).Value = Sortie_Tablo
    Dim y As Byte
    If Range("a1").Value = "" Then
    y = 1
    Else
    y = Range("a65535").End(xlUp).Row + 1
    End If
    Range("a" & y & ":f" & y + a).Value = Sortie_Tablo
    End Sub
    Merci de votre attenetion
    Daranc

  2. #2
    Membre Expert

    Homme Profil pro
    Technicien Métrologie R&D
    Inscrit en
    Janvier 2007
    Messages
    1 610
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 70
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Technicien Métrologie R&D
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 610
    Billets dans le blog
    1
    Par défaut
    Bon ben je m'excuse c'était un coup pour rien
    mes zone de stockage se servent de zone nommée pour des formule sommeprod qui totalise les cartons sur les plateaux (dans les zones StockRA B C D ) par contre le stock est lui aussi en zones nommée et comme je venais de purger le stock pour passer des test en saisie réelle mes sommeprod s'effectuer sur des zones vides (ou inexistantes ) un simple test SI(ESTVIDE(Stock!$A$2);0;puis la reprise de ma formule ) à regler ce problème )
    Désolé du déragement
    Daranc

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

Discussions similaires

  1. Problème avec Erreur 276 dans une boucle if
    Par Eldroth dans le forum Scilab
    Réponses: 0
    Dernier message: 31/05/2012, 16h57
  2. Erreur d'index sur une List<int> dans boucle for
    Par popoliline dans le forum C#
    Réponses: 13
    Dernier message: 16/06/2010, 11h03
  3. Erreur incompréhensible dans une boucle
    Par Neuromancien2 dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 07/08/2007, 16h48
  4. [Tableaux] Erreur dans Boucle
    Par mickado dans le forum Langage
    Réponses: 11
    Dernier message: 25/01/2007, 11h52
  5. [VB-E] Erreur 1004 dans une boucle For
    Par lycaon dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 02/11/2006, 22h41

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