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 :

Boucles IF non parcourue


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Femme Profil pro
    Ingénieur qualité méthodes
    Inscrit en
    Juillet 2016
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 31
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur qualité méthodes
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2016
    Messages : 2
    Par défaut Boucles IF non parcourue
    Bonjour,
    je commence à rédiger mes boucles IF ("J'en ai plein xD") mais le problème que VBA parfois il les exécutent parfois à chaque fois que j'ajoute des boucles il les exécutent pas je me suis peut être il y'a une limite...
    je suis débutante en VBA et je comprend pas la faille
    Merci d'avance !

  2. #2
    Rédacteur/Modérateur

    Avatar de Jean-Philippe André
    Homme Profil pro
    Architecte Power Platform, ex-Développeur VBA/C#/VB.Net
    Inscrit en
    Juillet 2007
    Messages
    14 682
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Canada

    Informations professionnelles :
    Activité : Architecte Power Platform, ex-Développeur VBA/C#/VB.Net
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2007
    Messages : 14 682
    Par défaut
    Bonjour,

    le fait d'avoir beaucoup de IF peut etre due a une mauvaise approche, pourrais-tu nous donner tout ou partie de ton code VBA afin que nous puissions de donner des idees ?
    Cycle de vie d'un bon programme :
    1/ ça fonctionne 2/ ça s'optimise 3/ ça se refactorise

    Pas de question technique par MP, je ne réponds pas

    Mes ouvrages :
    Migrer les applications VBA Access et VBA Excel vers la Power Platform
    Apprendre à programmer avec Access 2016, Access 2019 et 2021

    Apprendre à programmer avec VBA Excel
    Prise en main de Dynamics 365 Business Central

    Coffrets disponibles de mes ouvrages : https://www.editions-eni.fr/jean-philippe-andre
    Pensez à consulter la FAQ Excel et la FAQ Access

    Derniers tutos
    Excel et les paramètres régionaux
    Les fichiers Excel binaires : xlsb,

    Autres tutos

  3. #3
    Candidat au Club
    Femme Profil pro
    Ingénieur qualité méthodes
    Inscrit en
    Juillet 2016
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 31
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur qualité méthodes
    Secteur : Industrie

    Informations forums :
    Inscription : Juillet 2016
    Messages : 2
    Par défaut
    voilà une partie, c'est vraiment simple
    mais je comprend pas pourquoi à un certain moment il excécute pas
    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
    If (F1.Cells(i, 3) Like "CHAINES ET ENSEMBLE CHAINES" And F1.Cells(i, 4) Like "CHAINES" And F1.Cells(i, 5) Like "DIVERS") Then
      UserForm2.Label1.Caption = "BLANC"
      UserForm2.Label3.Caption = "CH 1 "
      End If
     If (F1.Cells(i, 3) Like "CHAINES ET ENSEMBLE CHAINES" And F1.Cells(i, 4) Like "ENSEMBLE CHAINES") Then
       UserForm2.Label1.Caption = "ROUGE"
        UserForm2.Label3.Caption = "ECH 4 "
    End If
    'CADRES
    If (F1.Cells(i, 3) Like "CADRES " And F1.Cells(i, 4) Like "CADRES SIMPLE") Then
        If F1.Cells(i, 5) Like "MURAKAMI " Then
          UserForm2.Label1.Caption = "ROUGE"
          UserForm2.Label3.Caption = "CD 1 "
    ElseIf F1.Cells(i, 5) Like "CONSTELLATION " Then
    UserForm2.Label1.Caption = "PISTACHE"
    UserForm2.Label3.Caption = "CD 3 "
    ElseIf F1.Cells(i, 5) Like "MATRICE" Then
           UserForm2.Label1.Caption = "MAUVE"
       UserForm2.Label3.Caption = "CD 3 "
       ElseIf F1.Cells(i, 5) Like "SECTION OVALE" Then
           UserForm2.Label1.Caption = "JAUNE"
         UserForm2.Label3.Caption = "CD 2 "
        ElseIf F1.Cells(i, 5) Like "MATRICE" Then
        UserForm2.Label1.Caption = "MAUVE"
        UserForm2.Label3.Caption = "CD 3 "
      Else: UserForm2.Label1.Caption = "VERT"
      UserForm2.Label3.Caption = "CD 2 "
         End If
    End If
     
          If (F1.Cells(i, 3) Like "CADRES " And F1.Cells(i, 4) Like "CADRES EMMANCHE") Then
               UserForm2.Label1.Caption = "VERT"
          UserForm2.Label3.Caption = "CD 2"
          End If
          If (F1.Cells(i, 3) Like "CADRES " And F1.Cells(i, 4) Like "CADRE ATTACHE BANDOULIERE") Then
               UserForm2.Label1.Caption = "BLEU"
          UserForm2.Label3.Caption = "CD 2"
          End If
          If (F1.Cells(i, 3) Like "CADRES " And F1.Cells(i, 4) Like "CADRE DE REGLAGE") Then
               UserForm2.Label1.Caption = "ROSE"
          UserForm2.Label3.Caption = "CD 2 "
          End If
          If (F1.Cells(i, 3) Like "CADRES " And F1.Cells(i, 4) Like "AUTRES CADRES") Then
               UserForm2.Label1.Caption = "XXX"
          UserForm2.Label3.Caption = "XXX"
     
          End If
    If (F1.Cells(i, 3) Like "PIECES D'ACCROCHAGE" And F1.Cells(i, 4) Like "ENCHAPES") Then
        If F1.Cells(i, 5) Like "DEMI ROND" Then
          UserForm2.Label1.Caption = "VERT"
          UserForm2.Label3.Caption = "EN 2 "
         ElseIf F1.Cells(i, 5) Like "ATTACHE BANDOULIERE" Then
          UserForm2.Label1.Caption = "MARRON"
          UserForm2.Label3.Caption = "EN 2"
        ElseIf F1.Cells(i, 5) Like "BAGUE" Then
          UserForm2.Label1.Caption = "JAUNE"
          UserForm2.Label3.Caption = "EN 2 "
        ElseIf F1.Cells(i, 5) Like "DIVERS" Then
          UserForm2.Label1.Caption = "TURQUOISE"
          UserForm2.Label3.Caption = "EN 1 "
       End If
       End If
    If F1.Cells(i, 3) Like "PIECES D'ACCROCHAGE" Then
         If Sheets("Feuille de données").Cells(i, 4) Like "BOUTON DE COL" Then
          UserForm2.Label1.Caption = "NOIR"
          UserForm2.Label3.Caption = "PA 1 "
         ElseIf F1.Cells(i, 4) Like "CHARNIERE" Then
          UserForm2.Label1.Caption = ""
          UserForm2.Label3.Caption = "PA 1 "
          ElseIf F1.Cells(i, 4) Like "PLOT D'ACCROCHAGE" Then
          UserForm2.Label1.Caption = "MARRON"
          UserForm2.Label3.Caption = "PA 2 "
          ElseIf F1.Cells(i, 4) Like "PONTET" Then
          UserForm2.Label1.Caption = ""
          UserForm2.Label3.Caption = "PA 2"
          ElseIf (F1.Cells(i, 4) Like "PASSANT" Or F1.Cells(i, 4) Like "PATIN") Then
          UserForm2.Label1.Caption = ""
         UserForm2.Label3.Caption = "PA 3 "
          ElseIf (F1.Cells(i, 4) Like "CROCHET" Or F1.Cells(i, 4) Like "CROCHET CINTRE") Then
          UserForm2.Label1.Caption = ""
         UserForm2.Label3.Caption = "PACC 1 "
     End If
      End If
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. Interruption d'une boucle - variable non définie
    Par Sérendipité dans le forum Programmation multimédia/Jeux
    Réponses: 14
    Dernier message: 16/04/2011, 22h53
  2. [XL-2003] Boucle FOR non linéaire
    Par JeanSairien dans le forum Macros et VBA Excel
    Réponses: 9
    Dernier message: 15/04/2010, 11h58
  3. Document XML non parcouru
    Par Guillomme dans le forum jQuery
    Réponses: 5
    Dernier message: 04/08/2009, 13h35
  4. Réponses: 14
    Dernier message: 20/05/2008, 13h09
  5. Boucle awk non finie
    Par zebulon90 dans le forum Shell et commandes GNU
    Réponses: 2
    Dernier message: 12/09/2007, 09h14

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