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 commande


Sujet :

Macros et VBA Excel

  1. #1
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut Problème de commande
    Bonsoir

    Je sollicite votre aide suite à des soucis dans un formulaire personnalisé :
    tout fonctionne sauf un bouton "modifié"
    j'ai vérifié la concordance des cellules aux colonnes, pas d'erreurs.
    Je vous joint le code en espérant que quelqu'un puisse résoudre mon problème: il s'agit du code de bouton "intégrer" et du bouton "modifier"
    Merci d'avance

    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
    Private Sub CommandButton1_Click()
     
        Dim L As Integer
     
        If MsgBox("Confirmez-vous l'insertion de cette nouvelle affaire ?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then
     
            'Pour placer le nouvel enregistrement à la première ligne de tableau non vide
            L = Sheets("Suivi").Range("A65536").End(xlUp).Row + 1
     
            Range("A" & L).Value = ComboBox1
            Range("B" & L).Value = TextBox2
            Range("C" & L).Value = TextBox5
            Range("D" & L).Value = TextBox3
            Range("E" & L).Value = TexBox6
            Range("F" & L).Value = TextBox4
            Range("G" & L).Value = TextBox54
            Range("H" & L).Value = TextBox8
            Range("I" & L).Value = ComboBox2
            Range("J" & L).Value = ComboBox3
            Range("K" & L).Value = TextBox11
            Range("L" & L).Value = ComboBox4
            Range("M" & L).Value = TextBox13
            Range("N" & L).Value = TextBox14
            Range("Q" & L).Value = TextBox15
            Range("S" & L).Value = TextBox53
            Range("T" & L).Value = TextBox16
            Range("U" & L).Value = TextBox17
            Range("V" & L).Value = TextBox18
            Range("W" & L).Value = TextBox19
            Range("X" & L).Value = TextBox20
            Range("Y" & L).Value = TextBox21
            Range("Z" & L).Value = TextBox22
            Range("AA" & L).Value = TextBox23
            Range("AB" & L).Value = TextBox24
            Range("AC" & L).Value = TextBox25
            Range("AE" & L).Value = TextBox26
            Range("AF" & L).Value = TextBox27
            Range("AG" & L).Value = TextBox28
            Range("AI" & L).Value = TextBox29
            Range("AM" & L).Value = TextBox30
            Range("AN" & L).Value = TextBox31
            Range("AS" & L).Value = TextBox32
            Range("AT" & L).Value = TextBox33
            Range("AX" & L).Value = TextBox34
            Range("AY" & L).Value = TextBox35
            Range("AZ" & L).Value = TextBox36
            Range("BA" & L).Value = TextBox37
            Range("BB" & L).Value = TextBox38
            Range("BC" & L).Value = TextBox39
            Range("BG" & L).Value = TextBox40
            Range("BH" & L).Value = TextBox41
            Range("BI" & L).Value = TextBox42
            Range("BJ" & L).Value = TextBox43
            Range("BK" & L).Value = TextBox44
            Range("BM" & L).Value = TextBox45
            Range("BN" & L).Value = TextBox46
            Range("BO" & L).Value = TextBox47
            Range("BP" & L).Value = TextBox48
            Range("BQ" & L).Value = TextBox49
            Range("BU" & L).Value = TextBox56
            Range("BV" & L).Value = TextBox50
            Range("BW" & L).Value = TextBox51
            Range("BX" & L).Value = TextBox52
     
            Unload Me
     
        End If
     
    End Sub
     
    Private Sub CommandButton2_Click()
     
        Dim lRow As Long, lCol As Long
        Dim i As Integer
     
        Worksheets("Suivi").Activate
     
        If MsgBox(" Confirmez-vous la modification de cette affaire ? ", vbYesNo, " Demande de confirmation de modification ") = vbYes Then
     
            If Me.ComboBox6.ListIndex = -1 Then Exit Sub
     
            lRow = Range("G" & Rows.Count).End(xlUp).Row
            lCol = Cells(lRow, Columns.Count).End(xlToLeft).Column
     
            Set result = Range("G2:G" & Range("G" & Rows.Count).End(xlUp).Row).Find(what:=ComboBox6.Text, LookAt:=xlWhole)
     
            If Not result Is Nothing Then
     
                Range("A" & result.Row).Value = ComboBox1
                Range("B" & result.Row).Value = TextBox2
                Range("C" & result.Row).Value = TextBox5
                Range("D" & result.Row).Value = TextBox3
                Range("E" & result.Row).Value = TexBox6
                Range("F" & result.Row).Value = TextBox4
                Range("G" & result.Row).Value = TextBox54
                Range("H" & result.Row).Value = TextBox8
                Range("I" & result.Row).Value = ComboBox2
                Range("J" & result.Row).Value = ComboBox3
                Range("K" & result.Row).Value = TextBox11
                Range("L" & result.Row).Value = ComboBox4
                Range("M" & result.Row).Value = TextBox13
                Range("N" & result.Row).Value = TextBox14
                Range("Q" & result.Row).Value = TextBox15
                Range("S" & result.Row).Value = TextBox53
                Range("T" & result.Row).Value = TextBox16
                Range("U" & result.Row).Value = TextBox17
                Range("V" & result.Row).Value = TextBox18
                Range("W" & result.Row).Value = TextBox19
                Range("X" & result.Row).Value = TextBox20
                Range("Y" & result.Row).Value = TextBox21
                Range("Z" & result.Row).Value = TextBox22
                Range("AA" & result.Row).Value = TextBox23
                Range("AB" & result.Row).Value = TextBox24
                Range("AC" & result.Row).Value = TextBox25
                Range("AE" & result.Row).Value = TextBox26
                Range("AF" & result.Row).Value = TextBox27
                Range("AG" & result.Row).Value = TextBox28
                Range("AI" & result.Row).Value = TextBox29
                Range("AM" & result.Row).Value = TextBox30
                Range("AN" & result.Row).Value = TextBox31
                Range("AS" & result.Row).Value = TextBox32
                Range("AT" & result.Row).Value = TextBox33
                Range("AX" & result.Row).Value = TextBox34
                Range("AY" & result.Row).Value = TextBox35
                Range("AZ" & result.Row).Value = TextBox36
                Range("BA" & result.Row).Value = TextBox37
                Range("BB" & result.Row).Value = TextBox38
                Range("BC" & result.Row).Value = TextBox39
                Range("BG" & result.Row).Value = TextBox40
                Range("BH" & result.Row).Value = TextBox41
                Range("BI" & result.Row).Value = TextBox42
                Range("BJ" & result.Row).Value = TextBox43
                Range("BK" & result.Row).Value = TextBox44
                Range("BM" & result.Row).Value = TextBox45
                Range("BN" & result.Row).Value = TextBox46
                Range("BO" & result.Row).Value = TextBox47
                Range("BP" & result.Row).Value = TextBox48
                Range("BQ" & result.Row).Value = TextBox49
                Range("BU" & result.Row).Value = TextBox56
                Range("BV" & result.Row).Value = TextBox50
                Range("BW" & result.Row).Value = TextBox51
                Range("BX" & result.Row).Value = TextBox52
     
                Unload Me
     
            Else
     
                MsgBox "Error!"
     
            End If
     
        End If
     
    End Sub

  2. #2
    Inactif  

    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2012
    Messages
    4 903
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2012
    Messages : 4 903
    Billets dans le blog
    36
    Par défaut Urgent + code non balisé + dimanche = bof !
    Inscrire urgent et ne pas mettre le code en forme, c'est le meilleur moyen de ne pas avoir de réponse.

    Après-tout, c'est dimanche.

  3. #3
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut


    Tu as raison, je joint carrément le fichier...

    Merci pour ta remarque
    Fichiers attachés Fichiers attachés

  4. #4
    Expert confirmé
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Par défaut
    Salut, Balise ton code du post 1.

  5. #5
    Membre Expert
    Inscrit en
    Octobre 2010
    Messages
    1 401
    Détails du profil
    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 401
    Par défaut
    Bonjour.

    Je crois que tu as des fautes de frappe :

    Le controle TexBox6 n'existe pas

    Le controle TextBox13 n'existe pas.

    Mets la commande
    en tête du code du Userform

  6. #6
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut
    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
    Private Sub CommandButton1_Click()
     
    Dim L As Integer
     
    If MsgBox("Confirmez-vous l'insertion de cette nouvelle affaire ?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then
     
    'Pour placer le nouvel enregistrement à la première ligne de tableau non vide
    L = Sheets("Suivi").Range("A65536").End(xlUp).Row + 1
     
    Range("A" & L).Value = ComboBox1
    Range("B" & L).Value = TextBox2
    Range("C" & L).Value = TextBox5
    Range("D" & L).Value = TextBox3
    Range("E" & L).Value = TexBox6
    Range("F" & L).Value = TextBox4
    Range("G" & L).Value = TextBox54
    Range("H" & L).Value = TextBox8
    Range("I" & L).Value = ComboBox2
    Range("J" & L).Value = ComboBox3
    Range("K" & L).Value = TextBox11
    Range("L" & L).Value = ComboBox4
    Range("M" & L).Value = TextBox13
    Range("N" & L).Value = TextBox14
    Range("Q" & L).Value = TextBox15
    Range("S" & L).Value = TextBox53
    Range("T" & L).Value = TextBox16
    Range("U" & L).Value = TextBox17
    Range("V" & L).Value = TextBox18
    Range("W" & L).Value = TextBox19
    Range("X" & L).Value = TextBox20
    Range("Y" & L).Value = TextBox21
    Range("Z" & L).Value = TextBox22
    Range("AA" & L).Value = TextBox23
    Range("AB" & L).Value = TextBox24
    Range("AC" & L).Value = TextBox25
    Range("AE" & L).Value = TextBox26
    Range("AF" & L).Value = TextBox27
    Range("AG" & L).Value = TextBox28
    Range("AI" & L).Value = TextBox29
    Range("AM" & L).Value = TextBox30
    Range("AN" & L).Value = TextBox31
    Range("AS" & L).Value = TextBox32
    Range("AT" & L).Value = TextBox33
    Range("AX" & L).Value = TextBox34
    Range("AY" & L).Value = TextBox35
    Range("AZ" & L).Value = TextBox36
    Range("BA" & L).Value = TextBox37
    Range("BB" & L).Value = TextBox38
    Range("BC" & L).Value = TextBox39
    Range("BG" & L).Value = TextBox40
    Range("BH" & L).Value = TextBox41
    Range("BI" & L).Value = TextBox42
    Range("BJ" & L).Value = TextBox43
    Range("BK" & L).Value = TextBox44
    Range("BM" & L).Value = TextBox45
    Range("BN" & L).Value = TextBox46
    Range("BO" & L).Value = TextBox47
    Range("BP" & L).Value = TextBox48
    Range("BQ" & L).Value = TextBox49
    Range("BU" & L).Value = TextBox56
    Range("BV" & L).Value = TextBox50
    Range("BW" & L).Value = TextBox51
    Range("BX" & L).Value = TextBox52
     
    Unload Me
     
    End If
     
    End Sub
     
    Private Sub CommandButton2_Click()
     
    Dim lRow As Long, lCol As Long
    Dim i As Integer
     
    Worksheets("Suivi").Activate
     
    If MsgBox(" Confirmez-vous la modification de cette affaire ? ", vbYesNo, " Demande de confirmation de modification ") = vbYes Then
     
    If Me.ComboBox6.ListIndex = -1 Then Exit Sub
     
    lRow = Range("G" & Rows.Count).End(xlUp).Row
    lCol = Cells(lRow, Columns.Count).End(xlToLeft).Column
     
    Set result = Range("G2:G" & Range("G" & Rows.Count).End(xlUp).Row).Find(what:=ComboBox6.Text, LookAt:=xlWhole)
     
    If Not result Is Nothing Then
     
    Range("A" & result.Row).Value = ComboBox1
    Range("B" & result.Row).Value = TextBox2
    Range("C" & result.Row).Value = TextBox5
    Range("D" & result.Row).Value = TextBox3
    Range("E" & result.Row).Value = TexBox6
    Range("F" & result.Row).Value = TextBox4
    Range("G" & result.Row).Value = TextBox54
    Range("H" & result.Row).Value = TextBox8
    Range("I" & result.Row).Value = ComboBox2
    Range("J" & result.Row).Value = ComboBox3
    Range("K" & result.Row).Value = TextBox11
    Range("L" & result.Row).Value = ComboBox4
    Range("M" & result.Row).Value = TextBox13
    Range("N" & result.Row).Value = TextBox14
    Range("Q" & result.Row).Value = TextBox15
    Range("S" & result.Row).Value = TextBox53
    Range("T" & result.Row).Value = TextBox16
    Range("U" & result.Row).Value = TextBox17
    Range("V" & result.Row).Value = TextBox18
    Range("W" & result.Row).Value = TextBox19
    Range("X" & result.Row).Value = TextBox20
    Range("Y" & result.Row).Value = TextBox21
    Range("Z" & result.Row).Value = TextBox22
    Range("AA" & result.Row).Value = TextBox23
    Range("AB" & result.Row).Value = TextBox24
    Range("AC" & result.Row).Value = TextBox25
    Range("AE" & result.Row).Value = TextBox26
    Range("AF" & result.Row).Value = TextBox27
    Range("AG" & result.Row).Value = TextBox28
    Range("AI" & result.Row).Value = TextBox29
    Range("AM" & result.Row).Value = TextBox30
    Range("AN" & result.Row).Value = TextBox31
    Range("AS" & result.Row).Value = TextBox32
    Range("AT" & result.Row).Value = TextBox33
    Range("AX" & result.Row).Value = TextBox34
    Range("AY" & result.Row).Value = TextBox35
    Range("AZ" & result.Row).Value = TextBox36
    Range("BA" & result.Row).Value = TextBox37
    Range("BB" & result.Row).Value = TextBox38
    Range("BC" & result.Row).Value = TextBox39
    Range("BG" & result.Row).Value = TextBox40
    Range("BH" & result.Row).Value = TextBox41
    Range("BI" & result.Row).Value = TextBox42
    Range("BJ" & result.Row).Value = TextBox43
    Range("BK" & result.Row).Value = TextBox44
    Range("BM" & result.Row).Value = TextBox45
    Range("BN" & result.Row).Value = TextBox46
    Range("BO" & result.Row).Value = TextBox47
    Range("BP" & result.Row).Value = TextBox48
    Range("BQ" & result.Row).Value = TextBox49
    Range("BU" & result.Row).Value = TextBox56
    Range("BV" & result.Row).Value = TextBox50
    Range("BW" & result.Row).Value = TextBox51
    Range("BX" & result.Row).Value = TextBox52
     
    Unload Me
     
    Else
     
    MsgBox "Error!"
     
    End If
     
    End If
     
    End Sub

    Merci pour vos réponses, j'espère que cette fois c'est bien codé...

  7. #7
    Membre chevronné
    Homme Profil pro
    autodidacte
    Inscrit en
    Novembre 2013
    Messages
    517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2013
    Messages : 517
    Par défaut
    Bonjour,

    Avancer en mode pas à pas via la touche F8 et voir ce qu'il se passe

  8. #8
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut
    Bonjour,
    Je n'y arrive pas
    C'est le bouton de commande dans le formulaire qui déconne ... le pas à pas pour macro je connais mais pas ça

    Docmarti avait raison sur un textbox, mais j'ai encore des erreurs : je comprends pas

  9. #9
    Membre chevronné
    Homme Profil pro
    autodidacte
    Inscrit en
    Novembre 2013
    Messages
    517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2013
    Messages : 517
    Par défaut
    C'est le bouton de commande dans le formulaire qui déconne ... le pas à pas pour macro je connais mais pas ça
    si vous connaissez le pas à pas et bien vous connaissez la touche F8 ou du moins c'est pour passer à l'étape suivante....

    Déjà, il faudrait savoir ce que doit faire ce bouton exactement. Ensuite, qu'est ce qui ne fonctionne pas? c'est très très vague...

  10. #10
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut
    En fait la combobox6 doit retrouver les informations déjà saisi et les faire apparaître dans le formulaire.
    Une fois à l'écran, l'idée est de modifier ou rajouter des informations, et les valider avec le bouton "modifier".

    Je suis pas expert, désolé si je suis flou par moment et encore merci pour votre aide...

    J'ai fais le pas à pas : apparemment la fonction marche mais j'ai remarqué que certaine cases restent vides qd je choisi une affaire avant modif, et bcp ne se modifient pas après avoir fait la commande "modifier"

  11. #11
    Membre Expert
    Inscrit en
    Octobre 2010
    Messages
    1 401
    Détails du profil
    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 401
    Par défaut
    Comme tu utilises Rowsource pour lire la colonne G, avant de faire une modification sur la colonne G, il faut supprimer temporairement la propriété RowSource.

    Exemple

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    mem = ComboBox6.RowSource
     ComboBox6.RowSource = ""
     
     Range("G" & result.Row).Value = TextBox54
     
     ComboBox6.RowSource = mem

  12. #12
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut
    OK j'ai essayé mais ca coince : je dois le placer en tête?

    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
    Private Sub CommandButton2_Click()
     
        Dim lRow As Long, lCol As Long
        Dim i As Integer
     
        Worksheets("Suivi").Activate
     
        If MsgBox(" Confirmez-vous la modification de cette affaire ? ", vbYesNo, " Demande de confirmation de modification ") = vbYes Then
     
            If Me.ComboBox6.ListIndex = -1 Then Exit Sub
     
            mem = ComboBox6.RowSource 'test
     
     ComboBox6.RowSource = ""
     
     Range("G" & result.Row).Value = TextBox54
     
     ComboBox6.RowSource = mem 'test
     
            lRow = Range("G" & Rows.Count).End(xlUp).Row
            lCol = Cells(lRow, Columns.Count).End(xlToLeft).Column
     
            Set result = Range("G2:G" & Range("G" & Rows.Count).End(xlUp).Row).Find(what:=ComboBox6.Text, LookAt:=xlWhole)
     
            If Not result Is Nothing Then
     
                Range("A" & result.Row).Value = ComboBox1
                Range("B" & result.Row).Value = TextBox2
                Range("C" & result.Row).Value = TextBox5
                Range("D" & result.Row).Value = TextBox3
                Range("E" & result.Row).Value = TexBox6
                Range("F" & result.Row).Value = TextBox4
                Range("G" & result.Row).Value = TextBox54
                Range("H" & result.Row).Value = TextBox8
                Range("I" & result.Row).Value = ComboBox2
                Range("J" & result.Row).Value = ComboBox3
                Range("K" & result.Row).Value = TextBox11
                Range("L" & result.Row).Value = ComboBox4
                Range("M" & result.Row).Value = ComboBox5
                Range("N" & result.Row).Value = TextBox14
                Range("Q" & result.Row).Value = TextBox15
                Range("S" & result.Row).Value = TextBox53
                Range("T" & result.Row).Value = TextBox16
                Range("U" & result.Row).Value = TextBox17
                Range("V" & result.Row).Value = TextBox18
                Range("W" & result.Row).Value = TextBox19
                Range("X" & result.Row).Value = TextBox20
                Range("Y" & result.Row).Value = TextBox21
                Range("Z" & result.Row).Value = TextBox22
                Range("AA" & result.Row).Value = TextBox23
                Range("AB" & result.Row).Value = TextBox24
                Range("AC" & result.Row).Value = TextBox25
                Range("AE" & result.Row).Value = TextBox26
                Range("AF" & result.Row).Value = TextBox27
                Range("AG" & result.Row).Value = TextBox28
                Range("AI" & result.Row).Value = TextBox29
                Range("AM" & result.Row).Value = TextBox30
                Range("AN" & result.Row).Value = TextBox31
                Range("AR" & result.Row).Value = TextBox57
                Range("AS" & result.Row).Value = TextBox32
                Range("AT" & result.Row).Value = TextBox33
                Range("AX" & result.Row).Value = TextBox34
                Range("AY" & result.Row).Value = TextBox35
                Range("AZ" & result.Row).Value = TextBox36
                Range("BA" & result.Row).Value = TextBox37
                Range("BB" & result.Row).Value = TextBox38
                Range("BC" & result.Row).Value = TextBox39
                Range("BG" & result.Row).Value = TextBox40
                Range("BH" & result.Row).Value = TextBox41
                Range("BI" & result.Row).Value = TextBox42
                Range("BJ" & result.Row).Value = TextBox43
                Range("BK" & result.Row).Value = TextBox44
                Range("BM" & result.Row).Value = TextBox45
                Range("BN" & result.Row).Value = TextBox46
                Range("BO" & result.Row).Value = TextBox47
                Range("BP" & result.Row).Value = TextBox48
                Range("BQ" & result.Row).Value = TextBox49
                Range("BU" & result.Row).Value = TextBox56
                Range("BV" & result.Row).Value = TextBox50
                Range("BW" & result.Row).Value = TextBox58
                Range("BX" & result.Row).Value = TextBox51
                Range("BX" & result.Row).Value = TextBox52
     
                Unload Me
     
            Else
     
                MsgBox "Error!"
     
            End If
     
        End If
     
    End Sub
    Je vais retester pour voir, merci

    ... Ca bloque à ce niveau :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Range("G" & result.Row).Value = TextBox54
    Mais je suis pas sur de bien le placer... Ca aurait une conséquence?

  13. #13
    Membre Expert
    Inscrit en
    Octobre 2010
    Messages
    1 401
    Détails du profil
    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 401
    Par défaut
    Non. Non.

    Comme ceci :

    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
    Private Sub CommandButton2_Click()
     
        Dim lRow As Long, lCol As Long
        Dim i As Integer
     
        Worksheets("Suivi").Activate
     
        If MsgBox(" Confirmez-vous la modification de cette affaire ? ", vbYesNo, " Demande de confirmation de modification ") = vbYes Then
     
            If Me.ComboBox6.ListIndex = -1 Then Exit Sub
     
     
     
            lRow = Range("G" & Rows.Count).End(xlUp).Row
            lCol = Cells(lRow, Columns.Count).End(xlToLeft).Column
     
            Set result = Range("G2:G" & Range("G" & Rows.Count).End(xlUp).Row).Find(what:=ComboBox6.Text, LookAt:=xlWhole)
     
            If Not result Is Nothing Then
     
     mem = ComboBox6.RowSource  
     
     ComboBox6.RowSource = ""
     
                Range("A" & result.Row).Value = ComboBox1
                Range("B" & result.Row).Value = TextBox2
                Range("C" & result.Row).Value = TextBox5
                Range("D" & result.Row).Value = TextBox3
                Range("E" & result.Row).Value = TexBox6
                Range("F" & result.Row).Value = TextBox4
                Range("G" & result.Row).Value = TextBox54
                Range("H" & result.Row).Value = TextBox8
                Range("I" & result.Row).Value = ComboBox2
                Range("J" & result.Row).Value = ComboBox3
                Range("K" & result.Row).Value = TextBox11
                Range("L" & result.Row).Value = ComboBox4
                Range("M" & result.Row).Value = ComboBox5
                Range("N" & result.Row).Value = TextBox14
                Range("Q" & result.Row).Value = TextBox15
                Range("S" & result.Row).Value = TextBox53
                Range("T" & result.Row).Value = TextBox16
                Range("U" & result.Row).Value = TextBox17
                Range("V" & result.Row).Value = TextBox18
                Range("W" & result.Row).Value = TextBox19
                Range("X" & result.Row).Value = TextBox20
                Range("Y" & result.Row).Value = TextBox21
                Range("Z" & result.Row).Value = TextBox22
                Range("AA" & result.Row).Value = TextBox23
                Range("AB" & result.Row).Value = TextBox24
                Range("AC" & result.Row).Value = TextBox25
                Range("AE" & result.Row).Value = TextBox26
                Range("AF" & result.Row).Value = TextBox27
                Range("AG" & result.Row).Value = TextBox28
                Range("AI" & result.Row).Value = TextBox29
                Range("AM" & result.Row).Value = TextBox30
                Range("AN" & result.Row).Value = TextBox31
                Range("AR" & result.Row).Value = TextBox57
                Range("AS" & result.Row).Value = TextBox32
                Range("AT" & result.Row).Value = TextBox33
                Range("AX" & result.Row).Value = TextBox34
                Range("AY" & result.Row).Value = TextBox35
                Range("AZ" & result.Row).Value = TextBox36
                Range("BA" & result.Row).Value = TextBox37
                Range("BB" & result.Row).Value = TextBox38
                Range("BC" & result.Row).Value = TextBox39
                Range("BG" & result.Row).Value = TextBox40
                Range("BH" & result.Row).Value = TextBox41
                Range("BI" & result.Row).Value = TextBox42
                Range("BJ" & result.Row).Value = TextBox43
                Range("BK" & result.Row).Value = TextBox44
                Range("BM" & result.Row).Value = TextBox45
                Range("BN" & result.Row).Value = TextBox46
                Range("BO" & result.Row).Value = TextBox47
                Range("BP" & result.Row).Value = TextBox48
                Range("BQ" & result.Row).Value = TextBox49
                Range("BU" & result.Row).Value = TextBox56
                Range("BV" & result.Row).Value = TextBox50
                Range("BW" & result.Row).Value = TextBox58
                Range("BX" & result.Row).Value = TextBox51
                Range("BX" & result.Row).Value = TextBox52
     
    ComboBox6.RowSource = mem 
     
                Unload Me
     
            Else
     
                MsgBox "Error!"
     
            End If
     
        End If
     
    End Sub

  14. #14
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut
    Désolé DocMarti ca ne fonctionne toujours 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
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    Private Sub CommandButton2_Click()
     
        Dim lRow As Long, lCol As Long
        Dim i As Integer
     
        Worksheets("Suivi").Activate
     
        If MsgBox(" Confirmez-vous la modification de cette affaire ? ", vbYesNo, " Demande de confirmation de modification ") = vbYes Then
     
            If Me.ComboBox6.ListIndex = -1 Then Exit Sub
     
     
     
            lRow = Range("G" & Rows.Count).End(xlUp).Row
            lCol = Cells(lRow, Columns.Count).End(xlToLeft).Column
     
            Set result = Range("G2:G" & Range("G" & Rows.Count).End(xlUp).Row).Find(what:=ComboBox6.Text, LookAt:=xlWhole)
     
            If Not result Is Nothing Then
     
     mem = ComboBox6.RowSource
     
     ComboBox6.RowSource = ""
     
                Range("A" & result.Row).Value = ComboBox1
                Range("B" & result.Row).Value = TextBox2
                Range("C" & result.Row).Value = TextBox5
                Range("D" & result.Row).Value = TextBox3
                Range("E" & result.Row).Value = TexBox6
                Range("F" & result.Row).Value = TextBox4
                Range("G" & result.Row).Value = TextBox54
                Range("H" & result.Row).Value = TextBox8
                Range("I" & result.Row).Value = ComboBox2
                Range("J" & result.Row).Value = ComboBox3
                Range("K" & result.Row).Value = TextBox11
                Range("L" & result.Row).Value = ComboBox4
                Range("M" & result.Row).Value = ComboBox5
                Range("N" & result.Row).Value = TextBox14
                Range("Q" & result.Row).Value = TextBox15
                Range("S" & result.Row).Value = TextBox53
                Range("T" & result.Row).Value = TextBox16
                Range("U" & result.Row).Value = TextBox17
                Range("V" & result.Row).Value = TextBox18
                Range("W" & result.Row).Value = TextBox19
                Range("X" & result.Row).Value = TextBox20
                Range("Y" & result.Row).Value = TextBox21
                Range("Z" & result.Row).Value = TextBox22
                Range("AA" & result.Row).Value = TextBox23
                Range("AB" & result.Row).Value = TextBox24
                Range("AC" & result.Row).Value = TextBox25
                Range("AE" & result.Row).Value = TextBox26
                Range("AF" & result.Row).Value = TextBox27
                Range("AG" & result.Row).Value = TextBox28
                Range("AI" & result.Row).Value = TextBox29
                Range("AM" & result.Row).Value = TextBox30
                Range("AN" & result.Row).Value = TextBox31
                Range("AR" & result.Row).Value = TextBox57
                Range("AS" & result.Row).Value = TextBox32
                Range("AT" & result.Row).Value = TextBox33
                Range("AX" & result.Row).Value = TextBox34
                Range("AY" & result.Row).Value = TextBox35
                Range("AZ" & result.Row).Value = TextBox36
                Range("BA" & result.Row).Value = TextBox37
                Range("BB" & result.Row).Value = TextBox38
                Range("BC" & result.Row).Value = TextBox39
                Range("BG" & result.Row).Value = TextBox40
                Range("BH" & result.Row).Value = TextBox41
                Range("BI" & result.Row).Value = TextBox42
                Range("BJ" & result.Row).Value = TextBox43
                Range("BK" & result.Row).Value = TextBox44
                Range("BM" & result.Row).Value = TextBox45
                Range("BN" & result.Row).Value = TextBox46
                Range("BO" & result.Row).Value = TextBox47
                Range("BP" & result.Row).Value = TextBox48
                Range("BQ" & result.Row).Value = TextBox49
                Range("BU" & result.Row).Value = TextBox56
                Range("BV" & result.Row).Value = TextBox50
                Range("BW" & result.Row).Value = TextBox58
                Range("BX" & result.Row).Value = TextBox51
                Range("BY" & result.Row).Value = TextBox52
     
    ComboBox6.RowSource = mem
     
                Unload Me
     
            Else
     
                MsgBox "Error!"
     
            End If
     
        End If
     
    End Sub
    Toujours pareil : il ne prend pas les modifs en compte...

  15. #15
    Membre chevronné
    Homme Profil pro
    autodidacte
    Inscrit en
    Novembre 2013
    Messages
    517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2013
    Messages : 517
    Par défaut
    autre alternative, changer de méthode:


    supprime la propriété rowsource de la combobox (mettre vide)

    et remplir la combobox comme ceci:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Private Sub UserForm_Initialize()
    Application.ScreenUpdating = False
    Dim i As Integer, x As Integer
    i = ThisWorkbook.Worksheets("Suivi").Range("G" & Rows.Count).End(xlUp).Row
    For x = 2 To i
        With Me.ComboBox6
            .AddItem ThisWorkbook.Worksheets("Suivi").Range("G" & x)
        End With
    Next x
    End Sub

    ceci dis, la méthode de Docmarti fonctionne normalement trsè bien. il faut juste remplacer le code du commandbutton2 par celui fourni par docmarti

  16. #16
    Membre chevronné
    Homme Profil pro
    autodidacte
    Inscrit en
    Novembre 2013
    Messages
    517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2013
    Messages : 517
    Par défaut
    Toujours pareil : il ne prend pas les modifs en compte...
    Quelles modifications ne prend-il pas en compte? Je viens de faire le test et chez moi les modifications sont prises en compte....

  17. #17
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut
    Ha bon??

    Je viens de re-essayer, par exemple qd on prends une affaire existante (par la combobox), je change le numéro de lot et qd je fais "modifier" rien ne change, et pire l'ancien disparait. CA SYADEN aussi : disparait dès que je choisi une affaire mais changement pris en compte.

    Après effectivement dans l'ensemble ca fonctionne .... Je vais retester

    Merci!!

    Plus d'info : CA SYADEN c'est rectifié (erreur dans le code) par contre toujours le problème dans "numéro de lot".
    Après tout marche. par contre j'ai detecté un soucis dans la colonne S ou case "montant affecté" : je faisais glisser la formule, mais si je fais une modification la formule disparait après validation de la modif.

    Serait-il possible de rentrer la formule dans la textbox??

  18. #18
    Membre chevronné
    Homme Profil pro
    autodidacte
    Inscrit en
    Novembre 2013
    Messages
    517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : autodidacte
    Secteur : Industrie

    Informations forums :
    Inscription : Novembre 2013
    Messages : 517
    Par défaut
    pour numéro de lot:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Range("E" & result.Row).Value = TexBox6
    il manque un T à textbox

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Range("E" & result.Row).Value = TextBox6
    par contre j'ai detecté un soucis dans la colonne S ou case "montant affecté" : je faisais glisser la formule, mais si je fais une modification la formule disparait après validation de la modif. Serait-il possible de rentrer la formule dans la textbox??
    voir l'aide excel sur formula, formulalocal, formulaR1C1

  19. #19
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut
    Rholala j'en suis honteux pour le T ...

    Merci beaucoup...

    Et je vais voir dans l'aide comme indiqué et je vous tiens informé

  20. #20
    Membre averti
    Homme Profil pro
    Chargé d'affaire
    Inscrit en
    Novembre 2015
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Aude (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Chargé d'affaire
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2015
    Messages : 12
    Par défaut
    Bonsoir,

    J'ai réussi avec FORMULA, reste juste un petit dernier soucis (comparé à tout ce que vous m'avez aidé à résoudre) la formule à une erreur du au case que je dois convertir en nombre.
    Je vais chercher une fonction pour les convertir directement en VBA.

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. besoin d aide urgent code C++ merci bp
    Par adomri dans le forum C++
    Réponses: 2
    Dernier message: 05/07/2007, 18h09

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