Re : Réinitialiser un userform
Bonjour JNP
Je vous transmettrais bien le ficher, mais son poids a pris l'ascensseur (même compressé), et il faudrait sûrement en plus des explication...
Avec les connaissance que j'ai !!! La juste page du multipage est sélectionnée lors de l'ouverture de l'Userform en fonction d'un chiffre donné sur ma feuille de calcul. Si cela peut vous éclairer sur mon problème, voici un bout de mon code, avec son initialisation.
Bonne fin de journée
Fred
Private Sub CommandRC_Click()
ActiveSheet.Unprotect password:="fdp"
Range("réduction").Select
Selection.Copy
DerniereLigne = Range("A65536").End(xlUp).Row + 1
Cells(DerniereLigne, 1).Select
ActiveSheet.Paste
Selection.EntireRow.Hidden = False 'affiche la ligne cachée
Application.CutCopyMode = False 'désélectionne la ligne copiée
unload me
panneau_commande.show 'fonctionne
End Sub
Private Sub CommandSPIRO_Click()
ActiveSheet.Unprotect password:="fdp"
Range("SPIRO").Select
Selection.Copy
DerniereLigne = Range("A65536").End(xlUp).Row + 1
Cells(DerniereLigne, 1).Select
ActiveSheet.Paste
Selection.EntireRow.Hidden = False 'affiche la ligne cachée
Application.CutCopyMode = False 'désélectionne la ligne copiée
UserForm_Initialize 'ne fontionne pas
'ActiveSheet.Protect password:="fdp"
End Sub
Private Sub Commandappliquer_Click()
dd = ActiveCell.Row
test = "bc" + CStr(dd)
If Range(test).Value = "1" Then 'Test qu'il n'y a aucune erreur avant de quitter
UserForm_Initialize 'ne fonctionne pas
Else
MsgBox "CORRIGER LES ERREURS AVANT D'APPLIQUER LES MODIFICATIONS, MERCI"
End If
End Sub
Private Sub Commandappliquer2_Click()
dd = ActiveCell.Row
test = "bc" + CStr(dd)
If Range(test).Value = "1" Then 'Test qu'il n'y a aucune erreur avant de quitter
Unload Me
panneau_commande.Show 'fonctionne
Else
MsgBox "CORRIGER LES ERREURS AVANT D'APPLIQUER LES MODIFICATIONS, MERCI"
End If
End Sub
Private Sub UserForm_Initialize()
'position du userform sur la feuille
With Me
.startUpPosition = 3
.Left = Application.Width - Me.Width
End With
dd = ActiveCell.Row
valmontage = "n" + CStr(dd)
valtype = "bb" + CStr(dd)
vallargeur = "d" + CStr(dd)
valhauteur = "e" + CStr(dd)
vallongueur = "f" + CStr(dd)
valpoids = "T" + CStr(dd)
valprix = "m" + CStr(dd)
valsurface = "L" + CStr(dd)
valtexttype1 = "y" + CStr(dd)
valtexttype2 = "as" + CStr(dd)
vallongspiro = "f" + CStr(dd)
valnombrespiro = "g" + CStr(dd)
panneau_commande.Texttype1.Value = Range(valtexttype1).Value
panneau_commande.Texttype2.Value = Range(valtexttype2).Value
If Range(valtype).Value = "1" Then 'page spiro
panneau_commande.Show
Me.MultiPage1.Value = 1
Me.MultiPage1.Pages(0).Visible = False
Me.MultiPage1.Pages(2).Visible = False
Me.MultiPage1.Pages(3).Visible = False
Me.MultiPage1.Pages(4).Visible = False
Me.MultiPage1.Pages(5).Visible = False
Me.MultiPage1.Pages(6).Visible = False
valnombrespiro = "g" + CStr(dd)
valisolation = "aw" + CStr(dd)
panneau_commande.Checkisol1.Value = Range(valisolation).Value
ComboDIAM1.RowSource = "bk1:bk20"
ComboDIAM1.ControlSource = "ab" + CStr(dd)
panneau_commande.Boxlongspiro.Value = Range(vallongspiro).Value
panneau_commande.Boxnombrespiro.Value = Range(valnombrespiro).Value
Else
If Range(valtype).Value = "0" Then 'Page rectangulaire
panneau_commande.Show
Me.MultiPage1.Value = 0
Me.MultiPage1.Pages(1).Visible = False
Me.MultiPage1.Pages(2).Visible = False
Me.MultiPage1.Pages(3).Visible = False
Me.MultiPage1.Pages(4).Visible = False
Me.MultiPage1.Pages(5).Visible = False
Me.MultiPage1.Pages(6).Visible = False
Combocadre1.RowSource = "be2:be8"
Combocadre1.ControlSource = "bf" + CStr(dd)
Combocadre2.RowSource = "be2:be8"
Combocadre2.ControlSource = "bg" + CStr(dd)
valnombre = "g" + CStr(dd)
valisolation4 = "aw" + CStr(dd)
positionisol = "ax" + CStr(dd)
positionisol2 = "be" + CStr(dd)
valétanchéité = "ba" + CStr(dd)
valfactmontage = "at" + CStr(dd)
panneau_commande.Checkétanche.Value = Range(valétanchéité).Value
panneau_commande.Optionisol.Value = Range(positionisol).Value
panneau_commande.Optionisol2.Value = Range(positionisol2).Value
panneau_commande.Checkisol4.Value = Range(valisolation4).Value
panneau_commande.boxlargeur.Value = Range(vallargeur).Value
panneau_commande.boxhauteur.Value = Range(valhauteur).Value
panneau_commande.boxlongueur.Value = Range(vallongueur).Value
panneau_commande.boxnombre.Value = Range(valnombre).Value
panneau_commande.Textpoids.Value = Range(valpoids).Value
panneau_commande.textmontage.Value = Range(valmontage).Value
panneau_commande.textprix.Value = Range(valprix).Value
panneau_commande.textsurface.Value = Range(valsurface).Value
panneau_commande.Textfactmontage = Range(valfactmontage).Value
Else
If Range(valtype).Value = "2" Then 'page spiro 2
panneau_commande.Show
Me.MultiPage1.Value = 2
Me.MultiPage1.Pages(0).Visible = False
Me.MultiPage1.Pages(1).Visible = False
Me.MultiPage1.Pages(3).Visible = False
Me.MultiPage1.Pages(4).Visible = False
Me.MultiPage1.Pages(5).Visible = False
Me.MultiPage1.Pages(6).Visible = False
valnombrespiro2 = "g" + CStr(dd)
valisolation2 = "aw" + CStr(dd)
panneau_commande.Checkisol2.Value = Range(valisolation2).Value
ComboDiam2.RowSource = "bk1:bk20"
ComboDiam2.ControlSource = "ab" + CStr(dd)
ComboDiam3.RowSource = "bk1:bk20"
ComboDiam3.ControlSource = "ac" + CStr(dd)
panneau_commande.Boxnombrespiro2.Value = Range(valnombrespiro2).Value
Else
If Range(valtype).Value = "3" Then 'page spiro 3
panneau_commande.Show
Me.MultiPage1.Value = 3
Me.MultiPage1.Pages(0).Visible = False
Me.MultiPage1.Pages(1).Visible = False
Me.MultiPage1.Pages(2).Visible = False
Me.MultiPage1.Pages(4).Visible = False
Me.MultiPage1.Pages(5).Visible = False
Me.MultiPage1.Pages(6).Visible = False
valnombrespiro3 = "g" + CStr(dd)
valisolation3 = "aw" + CStr(dd)
panneau_commande.Checkisol3.Value = Range(valisolation3).Value
ComboDiam4.RowSource = "bk1:bk20"
ComboDiam4.ControlSource = "ab" + CStr(dd)
panneau_commande.Boxnombrespiro3.Value = Range(valnombrespiro3).Value
Else
If Range(valtype).Value = "4" Then 'page text/position
panneau_commande.Show
Me.MultiPage1.Value = 4
Me.MultiPage1.Pages(0).Visible = False
Me.MultiPage1.Pages(1).Visible = False
Me.MultiPage1.Pages(2).Visible = False
Me.MultiPage1.Pages(3).Visible = False
Me.MultiPage1.Pages(5).Visible = False
Me.MultiPage1.Pages(6).Visible = False
valtextposition = "c" + CStr(dd)
valtextposition2 = "d" + CStr(dd)
panneau_commande.Textposition.Value = Range(valtextposition).Value
panneau_commande.Textposition2.Value = Range(valtextposition2).Value
Else
If Range(valtype).Value = "5" Then
panneau_commande.Show 'page pièce divers
Me.MultiPage1.Value = 5
Me.MultiPage1.Pages(0).Visible = False
Me.MultiPage1.Pages(1).Visible = False
Me.MultiPage1.Pages(2).Visible = False
Me.MultiPage1.Pages(3).Visible = False
Me.MultiPage1.Pages(4).Visible = False
Me.MultiPage1.Pages(6).Visible = False
valdenomination = "y" + CStr(dd)
valprixdivers = "q" + CStr(dd)
valmontagedivers = "s" + CStr(dd)
valsurfdivers = "r" + CStr(dd)
valisolation5 = "aw" + CStr(dd)
valtypedivers = "x" + CStr(dd)
panneau_commande.Texttypedivers = Range(valtypedivers).Value
panneau_commande.Textsurfisoldivers = Range(valsurfdivers).Value
panneau_commande.Textmontagedivers = Range(valmontagedivers).Value
panneau_commande.Textprixdivers = Range(valprixdivers).Value
panneau_commande.Textdenomination = Range(valdenomination).Value
panneau_commande.Boxnombrespiro4.Value = Range(valnombrespiro).Value
panneau_commande.Checkisol5.Value = Range(valisolation5).Value
Combodiam6.RowSource = "bk1:bk21"
Combodiam6.ControlSource = "ab" + CStr(dd)
Combodiam7.RowSource = "bk1:bk21"
Combodiam7.ControlSource = "ac" + CStr(dd)
Else
panneau_commande.Show 'rien de sélectionner
Me.MultiPage1.Value = 6
Me.MultiPage1.Pages(0).Visible = False
Me.MultiPage1.Pages(1).Visible = False
Me.MultiPage1.Pages(2).Visible = False
Me.MultiPage1.Pages(3).Visible = False
Me.MultiPage1.Pages(4).Visible = False
Me.MultiPage1.Pages(5).Visible = False
End If
End If
End If
End If
End If
End If
End Sub