Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

XL 2013 commandbutton a se suivre

grisan29

XLDnaute Accro
bonjour a tous et toutes

j'ai 5 boutons qui doivent ouvrir un userform sur lequel est posé un calendrier autonome avec un bouton qui écrit le choix dans un textbox mais comment fait que ce bouton réagissement en envoyant sa donné dans un autre textbox suivant quel bouton la demandé

j'ai fait un essai mais bug a commandbutton
Code:
Private Sub OK_Click()
If Me.CommandButton5.Select Then
    UserForm2.TB_date.Value = CDate(FormCal.Jour)
  Else
  If CommandButton6.Select Then
    UserForm2.TB_date1.Value = CDate(FormCal.Jour)
  Else
If CommandButton7.Select Then
    UserForm2.TB_date2.Value = CDate(FormCal.Jour)
  Else
If CommandButton8.Select Then
    UserForm2.TB_date3.Value = CDate(FormCal.Jour)
  Else
If CommandButton9.Select Then
    UserForm2.TB_date4.Value = CDate(FormCal.Jour)
  Else
  End If
    Unload Me
End Sub

car écrit comme ceci il fonctionne très bien pour un seul textbox
Code:
Private Sub OK_Click()
    UserForm2.TB_date.Value = CDate(FormCal.Jour) 
    Unload Me
End Sub

j'ai mis des select car avec des range ou des value le bug est le même
 
Dernière édition:

Lone-wolf

XLDnaute Barbatruc
Re : commandbutton a se suivre

Bonsoir Pascal,

un essai comme ceci

Code:
Private Sub OK_Click()
If Me.CommandButton5 Then
    UserForm2.TB_date.Value = CDate(FormCal.Jour)
ElseIf CommandButton6 Then
    UserForm2.TB_date1.Value = CDate(FormCal.Jour)
ElseIf CommandButton7 Then
    UserForm2.TB_date2.Value = CDate(FormCal.Jour)
ElseIf CommandButton8 Then
    UserForm2.TB_date3.Value = CDate(FormCal.Jour)
ElseIf CommandButton9 Then
    UserForm2.TB_date4.Value = CDate(FormCal.Jour)
Else
    Unload Me
End If
End Sub
 

grisan29

XLDnaute Accro
Re : commandbutton a se suivre

bonsoir lonewolf
merci de ta réponse mais le bug est toujours a commandbutton5 avec une erreur de compilation
j'ai fini par trouvé comment procédé
voila le code des boutons
Code:
Public txt As Control
    Private Sub CButton1_Click()
        Set txt = TB_date
        FormCal.Show
    End Sub

    Private Sub CButton2_Click()
       Set txt = TB_date1
        FormCal.Show
    End Sub

    Private Sub CButton3_Click()
        Set txt = TB_date2
        FormCal.Show
    End Sub

    Private Sub CButton4_Click()
        Set txt = TB_date3
        FormCal.Show
    End Sub

    Private Sub CommandButton5_Click()
        Set txt = TB_date4
        FormCal.Show
    End Sub

voila le code du bouton "ok"
Code:
Private Sub OK_Click()
 UserForm1.txt.Value = CDate(FormCal.Jour)

    Unload Me

End Sub
 
Dernière édition:

grisan29

XLDnaute Accro
Re : commandbutton a se suivre

bonsoir lone-wolf, thebenoit59 et le forum

je venais pour faire un complément car le code mis plus fonctionne très bien pour l'ajout de date dans le textbox
mais la ou ça se corse c'est qu'a partir du choix dans la combobox je n'arrive pas a faire venir les 5 dates correspondant au choix dans les TX_Date correspondant
bon j'ai ultra simplifier le classeur pour ne garder que l'essentiel mais en tout il y a 19 textbox et combobox

donc la combobox choix devrai remplir les textbox de la correspondance de la ligne comme pour GUEN CI DESSOUS
GUEN 18/11/2015 19/12/2015 21/12/2015 18/01/2016 05/02/2016

j'ai essayer comme ceci dans le code change du combonbox ,mais ce n'est pas la bonne ligne de date qui est inscrite
Code:
 UserForm1.TB_date.Value = Range("T" & I + 0).Value'ajout
    UserForm1.TB_date1.Value = Range("U" & I + 0).Value'ajout
     UserForm1.TB_date2.Value = Range("V" & I + 0).Value'ajout
      UserForm1.TB_date3.Value = Range("W" & I + 0).Value'ajout
       UserForm1.TB_date4.Value = Range("X" & I + 0).Value'ajout
 

Pièces jointes

  • essaicalendrierbis.xlsm
    33.6 KB · Affichages: 25
  • essaicalendrierbis.xlsm
    33.6 KB · Affichages: 23
Dernière édition:

Lone-wolf

XLDnaute Barbatruc
Re : commandbutton a se suivre

Bonsoir Pascal

Ton fichier en retour. J'ai ajouté un nouvelle colonne pour avoir les noms complets et utilisé la méthode Find pour la recherche des dates.

Regarde si celà te convient.
 

Pièces jointes

  • essaicalendrierbis.xlsm
    37 KB · Affichages: 27
  • essaicalendrierbis.xlsm
    37 KB · Affichages: 26
Dernière édition:

grisan29

XLDnaute Accro
Re : commandbutton a se suivre

bonsoir lone-wolf

merci pour le classeur qui fonctionne très bien et adapter dans le bon classeur c'est parfait

Merci a toi
 
Dernière édition:

Discussions similaires

Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…