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 incompatibilité de type


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Educateur Animateur
    Inscrit en
    Février 2013
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Educateur Animateur
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2013
    Messages : 132
    Par défaut Erreur incompatibilité de type
    Bonsoir à tous,

    Je suis confronté au problème suivant...

    'Incompatibilité de type' à la ligne

    pour le combobox2 (ici ligne 32)

    Alors que pour les autres ça fonctionne correctement...

    quelqu'un aurait une idée !?

    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
    'MISE A JOUR DES VALEURS DEPUIS LA COMBOBOX1
    Private Sub ComboBox1_Click()
     MajLiset Me.ComboBox1, Me.ComboBox2, Me.ComboBox3
     
     'pour trier l'affichage
     Dim Lig
     Dim Col
     Dim clé() As String, index() As Long, a(), b()
     a = Me.ListBox1.List
     ReDim b(LBound(a) To UBound(a), LBound(a, 2) To UBound(a, 2))
     ReDim clé(LBound(a) To UBound(a, 1))
     ReDim index(LBound(a) To UBound(a, 1))
     For i = LBound(a) To UBound(a, 1)
        clé(i) = a(i, 0) & a(i, 1): index(i) = i
      Next i
      Call Tri(clé(), index(), LBound(a), UBound(clé))
      For Lig = LBound(clé) To UBound(clé)
         For Col = LBound(a, 2) To UBound(a, 2): b(Lig, Col) = a(index(Lig), Col): Next Col
      Next Lig
      Me.ListBox1.List = b
     
    End Sub
     
    'MISE A JOUR DES VALEURS DEPUIS LA COMBOBOX2
    Private Sub ComboBox2_Click()
     MajLiset Me.ComboBox1, Me.ComboBox2, Me.ComboBox3
     
    'pour trier l'affichage
     Dim Lig
     Dim Col
     Dim clé() As String, index() As Long, a(), b()
     a = Me.ListBox1.List
     ReDim b(LBound(a) To UBound(a), LBound(a, 2) To UBound(a, 2))
     ReDim clé(LBound(a) To UBound(a, 1))
     ReDim index(LBound(a) To UBound(a, 1))
     For i = LBound(a) To UBound(a, 1)
        clé(i) = a(i, 0) & a(i, 1): index(i) = i
      Next i
      Call Tri(clé(), index(), LBound(a), UBound(clé))
      For Lig = LBound(clé) To UBound(clé)
         For Col = LBound(a, 2) To UBound(a, 2): b(Lig, Col) = a(index(Lig), Col): Next Col
      Next Lig
      Me.ListBox1.List = b
     
    End Sub
     
    'MISE A JOUR DES VALEURS DEPUIS LA COMBOBOX3
    Private Sub ComboBox3_Click()
     MajLiset Me.ComboBox1, Me.ComboBox2, Me.ComboBox3
     
    'pour trier l'affichage
     Dim Lig
     Dim Col
     Dim clé() As String, index() As Long, a(), b()
     a = Me.ListBox1.List
     ReDim b(LBound(a) To UBound(a), LBound(a, 2) To UBound(a, 2))
     ReDim clé(LBound(a) To UBound(a, 1))
     ReDim index(LBound(a) To UBound(a, 1))
     For i = LBound(a) To UBound(a, 1)
        clé(i) = a(i, 0) & a(i, 1): index(i) = i
      Next i
      Call Tri(clé(), index(), LBound(a), UBound(clé))
      For Lig = LBound(clé) To UBound(clé)
         For Col = LBound(a, 2) To UBound(a, 2): b(Lig, Col) = a(index(Lig), Col): Next Col
      Next Lig
      Me.ListBox1.List = b
     
    End Sub
     
    Sub Tri(clé() As String, index() As Long, gauc, droi) ' Quick sort
      Dim ref
      Dim g
      Dim d
      Dim temp
      ref = clé((gauc + droi) \ 2)
      g = gauc: d = droi
      Do
        Do While clé(g) < ref: g = g + 1: Loop
        Do While ref < clé(d): d = d - 1: Loop
        If g <= d Then
          temp = clé(g): clé(g) = clé(d): clé(d) = temp
          temp = index(g): index(g) = index(d): index(d) = temp
          g = g + 1: d = d - 1
        End If
      Loop While g <= d
      If g < droi Then Call Tri(clé, index, g, droi)
      If gauc < d Then Call Tri(clé, index, gauc, d)
    End Sub

  2. #2
    Membre confirmé
    Homme Profil pro
    Educateur Animateur
    Inscrit en
    Février 2013
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Educateur Animateur
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2013
    Messages : 132
    Par défaut
    Je rectifie... en fait ça ne fonctionne pas... l'erreur apparaît pour chaque combobox dès l'ouverture du userform

    A savoir, le même code fonctionne dans un autre userform mais il est intégré à un commandbutton...

  3. #3
    Membre confirmé
    Homme Profil pro
    Educateur Animateur
    Inscrit en
    Février 2013
    Messages
    132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Educateur Animateur
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2013
    Messages : 132
    Par défaut
    Je reviens vous voir... inutile de chercher, j'ai trouvé mon erreur... du code mal placé...

    Le code pour le tri qu'il ne fallait pas mettre dans chaque combobox_click, mais seulement dans

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Private Sub MajLiset(Combo1, Combo2, Combo3)

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

Discussions similaires

  1. [AC-2010] Erreur "incompatibilité de type"
    Par oreoolep dans le forum VBA Access
    Réponses: 4
    Dernier message: 02/12/2011, 21h29
  2. Erreur incompatibilité de type au lancement formulaire
    Par koluche dans le forum VBA Access
    Réponses: 0
    Dernier message: 05/05/2011, 14h59
  3. Erreur "incompatibilité de type" lors import dans table Access
    Par spud96 dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 05/01/2011, 21h40
  4. erreur incompatibilité de type
    Par prince19 dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 02/06/2007, 11h43
  5. [VBA E]erreur incompatibilité de type que je ne comprend pas
    Par zoumzoum59 dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 07/07/2006, 14h14

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