Problème UserForm effacer valeur avant ecriture et en annulant.

MIMI28CG

XLDnaute Nouveau
Bonjour à tous,

J'ai cherché partout pour résoudre mon problème et après avoir essayer plusieurs techniques, je n'y arrive toujours pas.

Voici mon problème :

J'aimerais que lorsque je click pour l'ouverture de mon Userform les valeurs à renseigner (dans l'onglet) s'efface et lorsque je click sur annuler toutes les données s'effacent.

Actuellement, je n'arrive qu'à effacer les données renseignées dans le Userform mais si vide rien ne s'efface.
Et avant l'ouverture, je n'arrive qu'à effacer les données du Userform.

Voici mes codes :
Code:
Option Explicit

Dim WS As Worksheet   'Variable pour un Objet Worksheet en PUBLIC pour tous les Controls de ce UserForm


Const T As String = "Saisie d'information"

Private Sub ComboBox2_Change()
[J12] = UserForm1.ComboBox2
End Sub


Private Sub CommandButton1_Click()

Dim x As Control
For Each x In rdv.Controls
If x.Value = True Then
Range("c12").Value = x.Caption
End If
Next
 Dim CTRL As Control
         
    'Boucle sur tous les contrôles
    For Each CTRL In Me.Controls
        'Vérifie qu'il s'agit d'un OptionButton
        If TypeOf CTRL Is MSForms.OptionButton Then
            'Véfifie si l'OptionButton fait partie d'un groupe 
             If CTRL.GroupName = "rdv" Then
                'Affiche le Caption de l'optionButton qui a la valeur True
                If CTRL.Value = True Then
                    MsgBox CTRL.Caption
                    'Sort de la boucle (Il ne peut y a voir qu'une
                    'réponse à True)
                    Exit For
                End If
            End If
        End If
    Next
    Unload UserForm1
    
End Sub

Private Sub CommandButton2_Click()

Me.ComboBox1.Value = ""
Me.OptionButton1.Value = ""
Me.TextBox1.Value = ""
Me.ComboBox2.Text = ""


Unload UserForm1

End
End Sub


Private Sub OptionButton1_Change()
[c12] = UserForm1.OptionButton1.Value

End Sub

Private Sub OptionButton2_Change()
[c12] = UserForm1.OptionButton2.Value

End Sub
Private Sub OptionButton3_Change()
[c12] = UserForm1.OptionButton3.Value
End Sub
Private Sub OptionButton4_Change()
[c12] = UserForm1.OptionButton4.Value

End Sub


Private Sub rdv_Click()
[c12] = UserForm1.rdv.Value
Dim CTRL As Control
    
    For Each CTRL In rdv.Controls
        CTRL.Enabled = Not CTRL.Enabled
    Next


End Sub

Private Sub TextBox1_Change()
[j10] = UserForm1.TextBox1.Value


End Sub

Private Sub UserForm_Initialize()
ComboBox1.RowSource = ("LISTING_MOIS")
ComboBox2.RowSource = ("LISTING_SEMAINE")
ComboBox1.Text = Format(Date, "mmmm-yyyy")


Set WS = ThisWorkbook.Sheets("FICHE RETOUR") 'On identifie l'objet pour la feuille de travail
'Pour éviter les fash d'écran pour le select ci dessous



Application.ScreenUpdating = True

End Sub
' A l'activation on démarre le focus sur la Première Combobox
Private Sub UserForm_Activate()
Me.ComboBox1.SetFocus


End Sub

Function Clear()

Range("c10").ClearContents
Range("c12").ClearContents
Range("j10").ClearContents
Range("j12").ClearContents

End Function




Private Sub ComboBox1_Change()
[c10] = UserForm1.ComboBox1
ComboBox1.Text = Format(ComboBox1.Text, "mmmm-yyyy")

End Sub

Private Sub UserForm_Click()

End Sub


Merci par avance pour toute aide de votre part...
 

Discussions similaires

Réponses
6
Affichages
202

Statistiques des forums

Discussions
311 709
Messages
2 081 756
Membres
101 812
dernier inscrit
trufu