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 :

USERFORM VBA EXCEL / Update Combobox, mise a jour boite texte


Sujet :

Macros et VBA Excel

  1. #1
    Futur Membre du Club
    Femme Profil pro
    autres
    Inscrit en
    Octobre 2016
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Canada

    Informations professionnelles :
    Activité : autres

    Informations forums :
    Inscription : Octobre 2016
    Messages : 13
    Points : 5
    Points
    5
    Par défaut USERFORM VBA EXCEL / Update Combobox, mise a jour boite texte
    Bonjour,

    J'ecris avec un clavier QWERTY donc desolee, je vais massacrer notre pauvre langue...

    Donc j'ai une question pour un userform sous excel 2016 dans VBA.
    J'ai cree une fonction recherche qui fonctionne, mais au moment de mettre a jour la donnee, c'est inactif.
    Ou peut etre mon erreur ? J'ai verifie pas a pas la video, mais je ne vois pas ce que j'ai oublie.


    Je vous mets le code et la video que j'ai utilise pour realiser une partie de mon formulaire, merci par avance de votre aide.

    CODE DE MA COMMANDE UPDATE
    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
    Private Sub CommandButton_Update_Click()
    Dim no_ligne As Integer
    Sheets("CONTACT LIST").Select
    no_ligne = ComboBox_Search.ListIndex + 3
    If ComboBox_Search.Value = "" Then
    MsgBox ("Update data")
    Else
    Cells(no_ligne, 1) = ComboBox_Status.Value
    Cells(no_ligne, 2) = TextBox_Lastupdate.Value
    Cells(no_ligne, 3) = textbox_Company.Value
    Cells(no_ligne, 4) = ComboBox_Activity.Value
    Cells(no_ligne, 5) = ComboBox_Position.Value
    Cells(no_ligne, 6) = ComboBox_Category.Value
    Cells(no_ligne, 7) = ComboBox_Topic.Value
    Cells(no_ligne, 8) = ComboBox_Code.Value
    Cells(no_ligne, 9) = ComboBox_Language.Value
    Cells(no_ligne, 10) = ComboBox_Title.Value
    Cells(no_ligne, 11) = textbox_Name.Value
    Cells(no_ligne, 12) = textbox_Surname.Value
    Cells(no_ligne, 13) = textbox_Address.Value
    Cells(no_ligne, 14) = textbox_Suite.Value
    Cells(no_ligne, 15) = textbox_City.Value
    Cells(no_ligne, 16) = textbox_Postalcode.Value
    Cells(no_ligne, 17) = textbox_Province.Value
    Cells(no_ligne, 18) = textbox_Country.Value
    Cells(no_ligne, 19) = textbox_Phone1.Value
    Cells(no_ligne, 20) = textbox_Phone2.Value
    Cells(no_ligne, 21).Value = Me.textbox_Email1.Value
    Cells(no_ligne, 22).Value = Me.textbox_Email2.Value
    Cells(no_ligne, 23).Value = Me.textbox_Fax.Value
    Cells(no_ligne, 24).Value = Me.textbox_Website.Value
    Cells(no_ligne, 25).Value = Me.textbox_Facebook.Value
    Cells(no_ligne, 26).Value = Me.textbox_Twitter.Value
    Cells(no_ligne, 27).Value = Me.textbox_Blog.Value
    Cells(no_ligne, 28).Value = Me.TextBox_Comments.Value
    End If
    End Sub


    ICI L'INTEGRALITE DU CODE DE MON FORMULAIRE
    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
    171
    172
    173
    174
    175
    176
    177
    Private Sub Cmdbutton_Add_Click()
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("CONTACT LIST")
     
    'find first empty row in database
    iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
     
    'check for a Name number
    If Trim(Me.textbox_Name.Value) = "" Then
    Me.textbox_Name.SetFocus
    MsgBox "Please complete the form"
    Exit Sub
    End If
     
    'copy the data to the database
    ws.Cells(iRow, 1).Value = Me.ComboBox_Status.Value
    ws.Cells(iRow, 2).Value = Me.TextBox_Lastupdate.Value
    ws.Cells(iRow, 3).Value = Me.textbox_Company.Value
    ws.Cells(iRow, 4).Value = Me.ComboBox_Activity.Value
    ws.Cells(iRow, 5).Value = Me.ComboBox_Position.Value
    ws.Cells(iRow, 6).Value = Me.ComboBox_Category.Value
    ws.Cells(iRow, 7).Value = Me.ComboBox_Topic.Value
    ws.Cells(iRow, 8).Value = Me.ComboBox_Code.Value
    ws.Cells(iRow, 9).Value = Me.ComboBox_Language.Value
    ws.Cells(iRow, 10).Value = Me.ComboBox_Title.Value
    ws.Cells(iRow, 11).Value = Me.textbox_Name.Value
    ws.Cells(iRow, 12).Value = Me.textbox_Surname.Value
    ws.Cells(iRow, 13).Value = Me.textbox_Address.Value
    ws.Cells(iRow, 14).Value = Me.textbox_Suite.Value
    ws.Cells(iRow, 15).Value = Me.textbox_City.Value
    ws.Cells(iRow, 16).Value = Me.textbox_Postalcode.Value
    ws.Cells(iRow, 17).Value = Me.textbox_Province.Value
    ws.Cells(iRow, 18).Value = Me.textbox_Country.Value
    ws.Cells(iRow, 19).Value = Me.textbox_Phone1.Value
    ws.Cells(iRow, 20).Value = Me.textbox_Phone2.Value
    ws.Cells(iRow, 21).Value = Me.textbox_Email1.Value
    ws.Cells(iRow, 22).Value = Me.textbox_Email2.Value
    ws.Cells(iRow, 23).Value = Me.textbox_Fax.Value
    ws.Cells(iRow, 24).Value = Me.textbox_Website.Value
    ws.Cells(iRow, 25).Value = Me.textbox_Facebook.Value
    ws.Cells(iRow, 26).Value = Me.textbox_Twitter.Value
    ws.Cells(iRow, 27).Value = Me.textbox_Blog.Value
    ws.Cells(iRow, 28).Value = Me.TextBox_Comments.Value
    MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
     
    'clear the data
    Me.ComboBox_Status.Value = ""
    Me.TextBox_Lastupdate.Value = ""
    Me.textbox_Company.Value = ""
    Me.ComboBox_Activity.Value = ""
    Me.ComboBox_Position.Value = ""
    Me.ComboBox_Category.Value = ""
    Me.ComboBox_Topic.Value = ""
    Me.ComboBox_Code.Value = ""
    Me.ComboBox_Language.Value = ""
    Me.ComboBox_Title.Value = ""
    Me.textbox_Name.Value = ""
    Me.textbox_Surname.Value = ""
    Me.textbox_Address.Value = ""
    Me.textbox_Suite.Value = ""
    Me.textbox_City.Value = ""
    Me.textbox_Postalcode.Value = ""
    Me.textbox_Province.Value = ""
    Me.textbox_Country.Value = ""
    Me.textbox_Phone1.Value = ""
    Me.textbox_Phone2.Value = ""
    Me.textbox_Email1.Value = ""
    Me.textbox_Email2.Value = ""
    Me.textbox_Fax.Value = ""
    Me.textbox_Website.Value = ""
    Me.textbox_Facebook.Value = ""
    Me.textbox_Twitter.Value = ""
    Me.textbox_Blog.Value = ""
    Me.TextBox_Comments.Value = ""
    Me.textbox_Name.SetFocus
    End Sub
     
    Private Sub Cmdbutton_Close_Click()
    Unload Me
    End Sub
     
    Private Sub ListBox1_Click()
    ComboBox1.List = Worksheets("Sheet1").Range("I1:I50").Value
    End Sub
     
     
    Private Sub ComboBox_Search_Change()
     
    End Sub
     
    Private Sub CommandButton_Update_Click()
    Dim no_ligne As Integer
    Sheets("CONTACT LIST").Select
    no_ligne = ComboBox_Search.ListIndex + 3
    If ComboBox_Search.Value = "" Then
    MsgBox ("Update data")
    Else
    Cells(no_ligne, 1) = ComboBox_Status.Value
    Cells(no_ligne, 2) = TextBox_Lastupdate.Value
    Cells(no_ligne, 3) = textbox_Company.Value
    Cells(no_ligne, 4) = ComboBox_Activity.Value
    Cells(no_ligne, 5) = ComboBox_Position.Value
    Cells(no_ligne, 6) = ComboBox_Category.Value
    Cells(no_ligne, 7) = ComboBox_Topic.Value
    Cells(no_ligne, 8) = ComboBox_Code.Value
    Cells(no_ligne, 9) = ComboBox_Language.Value
    Cells(no_ligne, 10) = ComboBox_Title.Value
    Cells(no_ligne, 11) = textbox_Name.Value
    Cells(no_ligne, 12) = textbox_Surname.Value
    Cells(no_ligne, 13) = textbox_Address.Value
    Cells(no_ligne, 14) = textbox_Suite.Value
    Cells(no_ligne, 15) = textbox_City.Value
    Cells(no_ligne, 16) = textbox_Postalcode.Value
    Cells(no_ligne, 17) = textbox_Province.Value
    Cells(no_ligne, 18) = textbox_Country.Value
    Cells(no_ligne, 19) = textbox_Phone1.Value
    Cells(no_ligne, 20) = textbox_Phone2.Value
    Cells(no_ligne, 21).Value = Me.textbox_Email1.Value
    Cells(no_ligne, 22).Value = Me.textbox_Email2.Value
    Cells(no_ligne, 23).Value = Me.textbox_Fax.Value
    Cells(no_ligne, 24).Value = Me.textbox_Website.Value
    Cells(no_ligne, 25).Value = Me.textbox_Facebook.Value
    Cells(no_ligne, 26).Value = Me.textbox_Twitter.Value
    Cells(no_ligne, 27).Value = Me.textbox_Blog.Value
    Cells(no_ligne, 28).Value = Me.TextBox_Comments.Value
    End If
    End Sub
     
     
    Private Sub CommandButton_search_Click()
    Dim no_ligne As Integer
    no_ligne = ComboBox_Search.ListIndex + 1
    ComboBox_Status.Value = Cells(no_ligne, 1).Value
    TextBox_Lastupdate.Value = Cells(no_ligne, 2).Value
    textbox_Company.Value = Cells(no_ligne, 3).Value
    ComboBox_Activity.Value = Cells(no_ligne, 4).Value
    ComboBox_Position.Value = Cells(no_ligne, 5).Value
    ComboBox_Category.Value = Cells(no_ligne, 6).Value
    ComboBox_Topic.Value = Cells(no_ligne, 7).Value
    ComboBox_Code.Value = Cells(no_ligne, 8).Value
    ComboBox_Language.Value = Cells(no_ligne, 9).Value
    ComboBox_Title.Value = Cells(no_ligne, 10).Value
    textbox_Name.Value = Cells(no_ligne, 11).Value
    textbox_Surname.Value = Cells(no_ligne, 12).Value
    textbox_Address.Value = Cells(no_ligne, 13).Value
    textbox_Suite.Value = Cells(no_ligne, 14).Value
    textbox_City.Value = Cells(no_ligne, 15).Value
    textbox_Postalcode.Value = Cells(no_ligne, 16).Value
    textbox_Province.Value = Cells(no_ligne, 17).Value
    textbox_Country.Value = Cells(no_ligne, 18).Value
     
    End Sub
    Private Sub textbox_City_Change()
    textbox_City.Value = UCase(textbox_City.Value)
    End Sub
     
    Private Sub textbox_Company_Change()
    textbox_Company.Value = UCase(textbox_Company.Value)
    End Sub
     
    Private Sub textbox_Company_Enter()
    textbox_Company.Value = UCase(textbox_Company.Value)
    End Sub
     
    Private Sub TextBox_Lastupdate_Enter()
    TextBox_Lastupdate.Text = Format(TextBox_Lastupdate.Value, "dd/mm/yyyy")
    End Sub
     
    Private Sub textbox_Province_Change()
    textbox_Province.Value = UCase(textbox_Province.Value)
    End Sub
     
    Private Sub UserForm_Initialize()
    Me.ScrollBars = fmScrollBarsVertical
    Me.ScrollHeight = Me.InsideHeight * 2
    End Sub
    ICI LA VIDEO QUE J'AI SUIVI

  2. #2
    Inactif  
    Homme Profil pro
    Analyste-Programmeur / Intégrateur ERP
    Inscrit en
    Mai 2013
    Messages
    2 511
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Analyste-Programmeur / Intégrateur ERP
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mai 2013
    Messages : 2 511
    Points : 10 335
    Points
    10 335
    Par défaut
    Bonjour,

    Je ne regarderais pas la vidéo (pas le temps), mais je doute fortement qu'il y soit indiqué de mettre une procédure, sans rien dedans :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Private Sub ComboBox_Search_Change()
    'Il devrait y avoir du code ici, sinon cette procédure ne sert à rien. 
    End Sub
    A votre place, je referais un petit tour complet, car ce n'est pas normal que cela soit ici sans rien dedans.


    Avez-vous tester la procédure de votre bouton d'update en mode pas à pas dans VBA, à l'aide d'un point d'arrêt, pour vérifier que la ligne à mettre à jour est bien trouvée déjà ?

  3. #3
    Futur Membre du Club
    Femme Profil pro
    autres
    Inscrit en
    Octobre 2016
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Canada

    Informations professionnelles :
    Activité : autres

    Informations forums :
    Inscription : Octobre 2016
    Messages : 13
    Points : 5
    Points
    5
    Par défaut
    Merci pour ta reponse.
    Le truc c'est que la foncttion marchait, mais comme j'avais un probleme de decalage de donnee, j'ai ajuste le tableau.
    Depuis, plus de decalage mais imcapable de mettre a jour.

    A savoir que cette section ci-dessous a toujours ete vide et que cela fonctionnait pourtant.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Private Sub ComboBox_Search_Change()
    'Il devrait y avoir du code ici, sinon cette procédure ne sert à rien. 
    End Sub

  4. #4
    Inactif  
    Homme Profil pro
    Analyste-Programmeur / Intégrateur ERP
    Inscrit en
    Mai 2013
    Messages
    2 511
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Analyste-Programmeur / Intégrateur ERP
    Secteur : Bâtiment

    Informations forums :
    Inscription : Mai 2013
    Messages : 2 511
    Points : 10 335
    Points
    10 335
    Par défaut
    Si la partie a toujours été vide et que cela fonctionnait, c'est qu'elle ne sert à rien et peut-être supprimée, ça évite de se poser des questions plus tard.

    Petite question, c'est normal que pour la recherche de la ligne, un coup c'est :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ComboBox_Search.ListIndex + 1
    et un autre :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ComboBox_Search.ListIndex + 3
    ?


    Qu'entends-tu par "j'ai ajusté le tableau" ? Tu l'a agrandi ? Décalé ? Car oui effectivement, cela peut expliquer le dysfonctionnement.

Discussions similaires

  1. [XL-2000] Userform VBA Excel
    Par Igloobel dans le forum Macros et VBA Excel
    Réponses: 7
    Dernier message: 12/04/2015, 13h49
  2. VBA Excel Update Combobox
    Par RastaBomboclat dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 26/11/2014, 12h30
  3. [VBA-EXcel] Timer pour mise jour automatique
    Par Dos dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 12/09/2006, 20h36
  4. [VBA Excel]. Pb de mise à jour de UserForm (checkBox)
    Par ExecelMans dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 16/08/2006, 11h06
  5. [VBA-Excel] Macro de mise à jour de Report
    Par strifer dans le forum Macros et VBA Excel
    Réponses: 22
    Dernier message: 13/07/2006, 11h23

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