Affichage d'un message à l'ouverture Userform

Bonjour,

Je souhaiterais pouvoir afficher un message à l'ouverture d'une Userform (exemple : "salut !"). Je sais qu'il faut utiliser le code "MsgBox pour l'afficher, mais ou le placer pour qu'il apparaisse dès l'ouverture de l'UserForm ?

Il s'agit d'une Userform appelé "climatisation" qui s'ouvre après avoir cliqué sur le bouton "Valider" ou "Suivant" de ma Userform précédente (CHnégative).

Voici le code de ma UserForm "CHnégative" :

Private Sub ComboBox871_Change()
Me.Label388.Visible = False
  If Me.ComboBox871.ListIndex = 0 Then
    Me.Label388.Visible = True
  End If
  Range("E16") = Me.ComboBox871.Value
End Sub

Private Sub ComboBox872_Change()
Me.Label389.Visible = False
  If Me.ComboBox872.ListIndex = 0 Then
    Me.Label389.Visible = True
  End If
  Range("F16") = Me.ComboBox872.Value
End Sub

Private Sub ComboBox873_Change()
Me.Label390.Visible = False
  If Me.ComboBox873.ListIndex = 0 Then
    Me.Label390.Visible = True
  End If
  Range("G16") = Me.ComboBox873.Value
End Sub

Private Sub ComboBox874_Change()
Me.Label391.Visible = False
  If Me.ComboBox874.ListIndex = 0 Then
    Me.Label391.Visible = True
  End If
  Range("H16") = Me.ComboBox874.Value
End Sub

Private Sub ComboBox875_Change()
Me.Label392.Visible = False
  If Me.ComboBox875.ListIndex = 0 Then
    Me.Label392.Visible = True
  End If
  Range("I16") = Me.ComboBox875.Value
End Sub

Private Sub ComboBox876_Change()
Me.Label401.Visible = False
  If Me.ComboBox876.ListIndex = 0 Then
    Me.Label401.Visible = True
  End If
  Range("J16") = Me.ComboBox876.Value
End Sub

Private Sub ComboBox877_Change()
Me.Label402.Visible = False
  If Me.ComboBox877.ListIndex = 0 Then
    Me.Label402.Visible = True
  End If
  Range("K16") = Me.ComboBox877.Value
End Sub

Private Sub ComboBox878_Change()
Me.Label403.Visible = False
  If Me.ComboBox878.ListIndex = 0 Then
    Me.Label403.Visible = True
  End If
  Range("L16") = Me.ComboBox878.Value
End Sub

Private Sub CommandButton26_Click()
CHnégative.Hide
Climatisation.Show
End Sub

Private Sub CommandButton27_Click()
'initialise la croix rouge (formulaire non complété)
Feuil1.Shapes("vert5").Visible = False
Feuil1.Shapes("rouge5").Visible = True

Dim confirmation As Variant
confirmation = MsgBox("Confirmez-vous la réinitialisation du formulaire ?" & Chr(10) & "(Si vous confirmez, votre saisie ne sera pas enregistrée)", vbYesNo, "Confirmation d'annulation")
If confirmation = vbYes Then
Unload CHnégative
CHnégative.Show
End If
End Sub

Private Sub CommandButton28_Click()
'initialise la flèche verte (formulaire complété)
Feuil1.Shapes("vert5").Visible = True
Feuil1.Shapes("rouge5").Visible = False

'Sélection de la feuille de calcul (ou écrire les infos)
Sheets("Chambres négative").Activate

' Utilité des chambres froides négatives
'CH 1
Range("E4") = ComboBox821.Value
'CH 2
Range("F4") = ComboBox822.Value
'CH 3
Range("G4") = ComboBox823.Value
'CH 4
Range("H4") = ComboBox824.Value
'CH 5
Range("I4") = ComboBox825.Value
'CH 6
Range("J4") = ComboBox826.Value
'CH 7
Range("K4") = ComboBox827.Value
'CH 8
Range("L4") = ComboBox828.Value

' Largeur des chambres froides négatives
'CH 1
Range("E7") = TextBox831.Value
'CH 2
Range("F7") = TextBox832.Value
'CH 3
Range("G7") = TextBox833.Value
'CH 4
Range("H7") = TextBox834.Value
'CH 5
Range("I7") = TextBox835.Value
'CH 6
Range("J7") = TextBox836.Value
'CH 7
Range("K7") = TextBox837.Value
'CH 8
Range("L7") = TextBox838.Value

' Longueur des chambres froides négatives
'CH 1
Range("E8") = TextBox841.Value
'CH 2
Range("F8") = TextBox842.Value
'CH 3
Range("G8") = TextBox843.Value
'CH 4
Range("H8") = TextBox844.Value
'CH 5
Range("I8") = TextBox845.Value
'CH 6
Range("J8") = TextBox846.Value
'CH 7
Range("K8") = TextBox847.Value
'CH 8
Range("L8") = TextBox848.Value

' Hauteur des chambres froides négatives
'CH 1
Range("E9") = TextBox851.Value
'CH 2
Range("F9") = TextBox852.Value
'CH 3
Range("G9") = TextBox853.Value
'CH 4
Range("H9") = TextBox854.Value
'CH 5
Range("I9") = TextBox855.Value
'CH 6
Range("J9") = TextBox856.Value
'CH 7
Range("K9") = TextBox857.Value
'CH 8
Range("L9") = TextBox858.Value

' évaporateurs existants ?
'CH 1
Range("E14") = ComboBox861.Value
'CH 2
Range("F14") = ComboBox862.Value
'CH 3
Range("G14") = ComboBox863.Value
'CH 4
Range("H14") = ComboBox864.Value
'CH 5
Range("I14") = ComboBox865.Value
'CH 6
Range("J14") = ComboBox866.Value
'CH 7
Range("K14") = ComboBox867.Value
'CH 8
Range("L14") = ComboBox868.Value

' Que voulez-vous en faire ?
'CH 1
Range("E15") = ComboBox871.Value
'CH 2
Range("F15") = ComboBox872.Value
'CH 3
Range("G15") = ComboBox873.Value
'CH 4
Range("H15") = ComboBox874.Value
'CH 5
Range("I15") = ComboBox875.Value
'CH 6
Range("J15") = ComboBox876.Value
'CH 7
Range("K15") = ComboBox877.Value
'CH 8
Range("L15") = ComboBox878.Value

erreur = MsgBox("Souhaitez vous enregistrer les informations saisies ?", vbYesNo, "saisie enregistrée")
If erreur = vbYes Then
demande = MsgBox("Vous allez maintenant passer à l'étape 6/6 !", vbOKOnly, " Passage à l'étape suivante")
CHnégative.Hide ' Cette commande masque le formulaire des chambres négatives tout en sauvegardant les infos saisies
Climatisation.Show
End If

End Sub

Private Sub CommandButton29_Click()
CHnégative.Hide
CHpositive.Show
End Sub

Private Sub CommandButton30_Click()
CHnégative.Hide
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' empêche la fermeture de la fenêtre par la croix rouge
    Cancel = CloseMode = 0
End Sub
Private Sub UserForm_Initialize()
Dim J As Integer
  For J = Sheets("Informations").Range("G46") + 1 To 8
    Me.Controls("TextBox" & 1100 + J).Visible = False
    Me.Controls("TextBox" & 830 + J).Visible = False
    Me.Controls("TextBox" & 840 + J).Visible = False
    Me.Controls("TextBox" & 850 + J).Visible = False
    Me.Controls("ComboBox" & 820 + J).Visible = False
    Me.Controls("ComboBox" & 860 + J).Visible = False
    Me.Controls("ComboBox" & 870 + J).Visible = False
 Next J

' listes déroulantes utilité de la chambre froide négative (sélection des infos contenues dans la liste corespondante)
ComboBox821.List = ThisWorkbook.Sheets("formulaire1").Range("E72:E73").Value
ComboBox822.List = ThisWorkbook.Sheets("formulaire1").Range("E72:E73").Value
ComboBox823.List = ThisWorkbook.Sheets("formulaire1").Range("E72:E73").Value
ComboBox824.List = ThisWorkbook.Sheets("formulaire1").Range("E72:E73").Value
ComboBox825.List = ThisWorkbook.Sheets("formulaire1").Range("E72:E73").Value
ComboBox826.List = ThisWorkbook.Sheets("formulaire1").Range("E72:E73").Value
ComboBox827.List = ThisWorkbook.Sheets("formulaire1").Range("E72:E73").Value
ComboBox828.List = ThisWorkbook.Sheets("formulaire1").Range("E72:E73").Value

' évaporateurs existants ? (sélection des infos contenues de la liste déroulante)
ComboBox861.List = ThisWorkbook.Sheets("formulaire1").Range("C72:C73").Value
ComboBox862.List = ThisWorkbook.Sheets("formulaire1").Range("C72:C73").Value
ComboBox863.List = ThisWorkbook.Sheets("formulaire1").Range("C72:C73").Value
ComboBox864.List = ThisWorkbook.Sheets("formulaire1").Range("C72:C73").Value
ComboBox865.List = ThisWorkbook.Sheets("formulaire1").Range("C72:C73").Value
ComboBox866.List = ThisWorkbook.Sheets("formulaire1").Range("C72:C73").Value
ComboBox867.List = ThisWorkbook.Sheets("formulaire1").Range("C72:C73").Value
ComboBox868.List = ThisWorkbook.Sheets("formulaire1").Range("C72:C73").Value

' voulez-vous les récupérer les évapo ? (sélection des infos contenues dans la liste déroulante)
ComboBox871.List = ThisWorkbook.Sheets("formulaire1").Range("D72:D73").Value
ComboBox872.List = ThisWorkbook.Sheets("formulaire1").Range("D72:D73").Value
ComboBox873.List = ThisWorkbook.Sheets("formulaire1").Range("D72:D73").Value
ComboBox874.List = ThisWorkbook.Sheets("formulaire1").Range("D72:D73").Value
ComboBox875.List = ThisWorkbook.Sheets("formulaire1").Range("D72:D73").Value
ComboBox876.List = ThisWorkbook.Sheets("formulaire1").Range("D72:D73").Value
ComboBox877.List = ThisWorkbook.Sheets("formulaire1").Range("D72:D73").Value
ComboBox878.List = ThisWorkbook.Sheets("formulaire1").Range("D72:D73").Value

Feuil1.Shapes("vert5").Visible = False
Feuil1.Shapes("rouge5").Visible = False

'initialise l'afichage "vérifier la puissance de l'évap" dans ma userform CHnégative
Me.Label388.Visible = False
Me.Label389.Visible = False
Me.Label390.Visible = False
Me.Label391.Visible = False
Me.Label392.Visible = False
Me.Label401.Visible = False
Me.Label402.Visible = False
Me.Label403.Visible = False
End Sub

et celui de la Userform suivante qui est "climatisation :

Private Sub CommandButton26_Click()
Climatisation.Hide
Récap.Show
End Sub
Private Sub CommandButton27_Click()
Climatisation.Hide
End Sub

Private Sub CommandButton29_Click()
'initialise la croix rouge (formulaire non complété)
Feuil1.Shapes("vert6").Visible = False
Feuil1.Shapes("rouge6").Visible = True
Dim confirmation As Variant
confirmation = MsgBox("Confirmez-vous la réinitialisation du formulaire ?" & Chr(10) & "(Si vous confirmez, votre saisie ne sera pas enregistrée)", vbYesNo, "Confirmation d'annulation")
If confirmation = vbYes Then
Unload Climatisation
Climatisation.Show
End If
End Sub

Private Sub CommandButton31_Click()
'initialise la flèche verte (formulaire complété)
Feuil1.Shapes("vert6").Visible = True
Feuil1.Shapes("rouge6").Visible = False

'sélection de la feuilles de calcul (ou écrire les infos)
Sheets("Clim existante").Activate

' Fluide utilisé ?
'Clim 1
Range("E2") = ComboBox911.Value
'Clim 2
Range("E7") = ComboBox912.Value
'Clim 3
Range("E11") = ComboBox913.Value
'Clim 4
Range("E15") = ComboBox914.Value
'Clim 5
Range("E19") = ComboBox915.Value
'Clim 6
Range("E24") = ComboBox916.Value
'Clim 7
Range("E28") = ComboBox917.Value
'Clim 8
Range("E32") = ComboBox918.Value
'Clim 9
Range("E36") = ComboBox919.Value
'Clim 10
Range("E40") = ComboBox920.Value

' Puissance de la clim ?
'Clim 1
Range("E3") = TextBox921.Value
'Clim 2
Range("E8") = TextBox922.Value
'Clim 3
Range("E12") = TextBox923.Value
'Clim 4
Range("E16") = TextBox924.Value
'Clim 5
Range("E20") = TextBox925.Value
'Clim 6
Range("E25") = TextBox926.Value
'Clim 7
Range("E29") = TextBox927.Value
'Clim 8
Range("E33") = TextBox928.Value
'Clim 9
Range("E37") = TextBox929.Value
'Clim 10
Range("E41") = TextBox930.Value

erreur = MsgBox("Souhaitez vous enregistrer les informations saisies ?", vbYesNo, "saisie enregistrée")
If erreur = vbYes Then
demande = MsgBox("Vous avez terminé ! Découvrez maintenant les récapitulatifs de votre saisie.", vbOKOnly)
End If
Climatisation.Hide ' permet de masquer le formulaire en conservant les informations saisies
Récap.Show

End Sub

Private Sub CommandButton32_Click()
Climatisation.Hide
CHnégative.Show
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' inhibe la fermeture par la croix rouge
    Cancel = CloseMode = 0
End Sub
Private Sub UserForm_Initialize()
Dim I As Integer
  For I = Sheets("Informations").Range("G34") + 1 To 10
    Me.Controls("Label" & 940 + I).Visible = False
    Me.Controls("ComboBox" & 910 + I).Visible = False
    Me.Controls("TextBox" & 920 + I).Visible = False

  Next I
' quel est le fluide utilisé ?
ComboBox911.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox912.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox913.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox914.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox915.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox916.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox917.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox918.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox919.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox920.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value

Feuil1.Shapes("vert6").Visible = False
Feuil1.Shapes("rouge6").Visible = False

End Sub

En espérant obtenir de l'aide ! merci

Bonjour Lamonfle,

il suffit de placer ce code dans le userform en question :

Private Sub UserForm_Initialize()

MsgBox ("salut !")

End Sub

Bonjour GIGA et merci pour ta réponse !

Malheureusement ce n'est pas ce que j'aimerais avoir. En réalité, je voudrais afficher le message si dans la cellule "G33" de ma feuille "Informations" la valeur "NON" apparaît.

J'ai essayé ceci que j'ai intégré sur le bouton "valider" de ma feuille "CHnégative" :

If Sheets("Informations").Cells("G33") = "OUI" Then
CHnégative.Hide
Climatisation.Show
End If

If Sheets("informations").Cells("G33") = "NON" Then
MsgBox ("Aucune climatisation(s)à récupérer !"), vbOKOnly, ("vous avez terminé")
CHnégative.Hide
Récap.Show
End If

Mais ça ne fonctionne pas..........

Ok, je pense qu'il suffit d'ajouter une condition toujours dans le UserForm Climatisation et dans l'événement : Private Sub UserForm_Initialize()

ce qui donne :

Private Sub UserForm_Initialize()
    If Sheets("Informations").range("G33") = "NON" Then
          MsgBox ("Aucune climatisation(s)à récupérer !")
          Unload Climatisation
    end if
end sub

ici quand le UserForm Climatisation s'ouvre si en cellule G33 il y a marqué "NON" alors un message s'affichera et le Userform se fermera, sinon le UserForm s'ouvrira normalement

Merci Giga, j'ai intégré ton code dans ma Userformr "climatisation", ça fonctionne en partie mais un nouveau problème fait son apparition !

En fait, dans le bouton "valider" de ma feuille "CHnégative", je fais appel à la fin de la procédure à ma Userform suivant à savoir "Climatisation". Voici le code :

Private Sub CommandButton28_Click() ' bouton valider
'initialise la flèche verte (formulaire complété)
Feuil1.Shapes("vert5").Visible = True
Feuil1.Shapes("rouge5").Visible = False

'Sélection de la feuille de calcul (ou écrire les infos)
Sheets("Chambres négative").Activate

' Utilité des chambres froides négatives
'CH 1
Range("E4") = ComboBox821.Value
'CH 2
Range("F4") = ComboBox822.Value
'CH 3
Range("G4") = ComboBox823.Value
'CH 4
Range("H4") = ComboBox824.Value
'CH 5
Range("I4") = ComboBox825.Value
'CH 6
Range("J4") = ComboBox826.Value
'CH 7
Range("K4") = ComboBox827.Value
'CH 8
Range("L4") = ComboBox828.Value

' Largeur des chambres froides négatives
'CH 1
Range("E7") = TextBox831.Value
'CH 2
Range("F7") = TextBox832.Value
'CH 3
Range("G7") = TextBox833.Value
'CH 4
Range("H7") = TextBox834.Value
'CH 5
Range("I7") = TextBox835.Value
'CH 6
Range("J7") = TextBox836.Value
'CH 7
Range("K7") = TextBox837.Value
'CH 8
Range("L7") = TextBox838.Value

' Longueur des chambres froides négatives
'CH 1
Range("E8") = TextBox841.Value
'CH 2
Range("F8") = TextBox842.Value
'CH 3
Range("G8") = TextBox843.Value
'CH 4
Range("H8") = TextBox844.Value
'CH 5
Range("I8") = TextBox845.Value
'CH 6
Range("J8") = TextBox846.Value
'CH 7
Range("K8") = TextBox847.Value
'CH 8
Range("L8") = TextBox848.Value

' Hauteur des chambres froides négatives
'CH 1
Range("E9") = TextBox851.Value
'CH 2
Range("F9") = TextBox852.Value
'CH 3
Range("G9") = TextBox853.Value
'CH 4
Range("H9") = TextBox854.Value
'CH 5
Range("I9") = TextBox855.Value
'CH 6
Range("J9") = TextBox856.Value
'CH 7
Range("K9") = TextBox857.Value
'CH 8
Range("L9") = TextBox858.Value

' évaporateurs existants ?
'CH 1
Range("E14") = ComboBox861.Value
'CH 2
Range("F14") = ComboBox862.Value
'CH 3
Range("G14") = ComboBox863.Value
'CH 4
Range("H14") = ComboBox864.Value
'CH 5
Range("I14") = ComboBox865.Value
'CH 6
Range("J14") = ComboBox866.Value
'CH 7
Range("K14") = ComboBox867.Value
'CH 8
Range("L14") = ComboBox868.Value

' Que voulez-vous en faire ?
'CH 1
Range("E15") = ComboBox871.Value
'CH 2
Range("F15") = ComboBox872.Value
'CH 3
Range("G15") = ComboBox873.Value
'CH 4
Range("H15") = ComboBox874.Value
'CH 5
Range("I15") = ComboBox875.Value
'CH 6
Range("J15") = ComboBox876.Value
'CH 7
Range("K15") = ComboBox877.Value
'CH 8
Range("L15") = ComboBox878.Value

erreur = MsgBox("Souhaitez vous enregistrer les informations saisies ?", vbYesNo, "saisie enregistrée")
If erreur = vbYes Then
demande = MsgBox("Vous allez maintenant passer à l'étape 6/6 !", vbOKOnly, " Passage à l'étape suivante")
CHnégative.Hide ' Cette commande masque le formulaire des chambres négatives tout en sauvegardant les infos saisies
End If
Climatisation.Show
End Sub

Or, quand la cellule "G33" prend la valeur "NON", une fois que l'on clique sur ce bouton "valider", un message d'erreur apparaît : "erreur d’exécution 91 variable ou objet de bloc with non définie." or je n'ai pas de bloc with !

je remet le code de ma Userform climatisation au cas ou :

Private Sub CommandButton26_Click()
Climatisation.Hide
Récap.Show
End Sub
Private Sub CommandButton27_Click()
Climatisation.Hide
End Sub

Private Sub CommandButton29_Click()
'initialise la croix rouge (formulaire non complété)
Feuil1.Shapes("vert6").Visible = False
Feuil1.Shapes("rouge6").Visible = True
Dim confirmation As Variant
confirmation = MsgBox("Confirmez-vous la réinitialisation du formulaire ?" & Chr(10) & "(Si vous confirmez, votre saisie ne sera pas enregistrée)", vbYesNo, "Confirmation d'annulation")
If confirmation = vbYes Then
Unload Climatisation
Climatisation.Show
End If
End Sub

Private Sub CommandButton31_Click()
'initialise la flèche verte (formulaire complété)
Feuil1.Shapes("vert6").Visible = True
Feuil1.Shapes("rouge6").Visible = False

'sélection de la feuilles de calcul (ou écrire les infos)
Sheets("Clim existante").Activate

' Fluide utilisé ?
'Clim 1
Range("E2") = ComboBox911.Value
'Clim 2
Range("E7") = ComboBox912.Value
'Clim 3
Range("E11") = ComboBox913.Value
'Clim 4
Range("E15") = ComboBox914.Value
'Clim 5
Range("E19") = ComboBox915.Value
'Clim 6
Range("E24") = ComboBox916.Value
'Clim 7
Range("E28") = ComboBox917.Value
'Clim 8
Range("E32") = ComboBox918.Value
'Clim 9
Range("E36") = ComboBox919.Value
'Clim 10
Range("E40") = ComboBox920.Value

' Puissance de la clim ?
'Clim 1
Range("E3") = TextBox921.Value
'Clim 2
Range("E8") = TextBox922.Value
'Clim 3
Range("E12") = TextBox923.Value
'Clim 4
Range("E16") = TextBox924.Value
'Clim 5
Range("E20") = TextBox925.Value
'Clim 6
Range("E25") = TextBox926.Value
'Clim 7
Range("E29") = TextBox927.Value
'Clim 8
Range("E33") = TextBox928.Value
'Clim 9
Range("E37") = TextBox929.Value
'Clim 10
Range("E41") = TextBox930.Value

erreur = MsgBox("Souhaitez vous enregistrer les informations saisies ?", vbYesNo, "saisie enregistrée")
If erreur = vbYes Then
demande = MsgBox("Vous avez terminé ! Découvrez maintenant les récapitulatifs de votre saisie.", vbOKOnly)
End If
Climatisation.Hide ' permet de masquer le formulaire en conservant les informations saisies
Récap.Show

End Sub

Private Sub CommandButton32_Click()
Climatisation.Hide
CHnégative.Show
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) ' inhibe la fermeture par la croix rouge
    Cancel = CloseMode = 0
End Sub
Private Sub UserForm_Initialize()

If Sheets("Informations").Range("G33") = "NON" Then
MsgBox ("Aucune climatisation(s)à récupérer !")
Unload Climatisation
End If

Dim I As Integer
  For I = Sheets("Informations").Range("G34") + 1 To 10
    Me.Controls("Label" & 940 + I).Visible = False
    Me.Controls("ComboBox" & 910 + I).Visible = False
    Me.Controls("TextBox" & 920 + I).Visible = False

  Next I
' quel est le fluide utilisé ?
ComboBox911.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox912.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox913.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox914.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox915.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox916.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox917.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox918.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox919.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value
ComboBox920.List = ThisWorkbook.Sheets("formulaire1").Range("A93:A110").Value

Feuil1.Shapes("vert6").Visible = False
Feuil1.Shapes("rouge6").Visible = False

End Sub

En espérant pouvoir résoudre ce problème qui m'embête au plus haut point alors que je suis sur qu'une toute petite bêtise se cache quelque part !

Bonjour Lamoufle,

Oui alors la solution est de passer par une constante, le code :

en haut d'un module :

Public test As Boolean

Puis dans le bouton valider à la fin :

Test = true

Puis dans le userform climatisation :

Private Sub UserForm_Initialize()
If Test = fase then

       If Sheets("Informations").range("G33") = "NON" Then
       MsgBox ("Aucune climatisation(s)à récupérer !")
       Unload Climatisation
       end if

end if

'ne pas oublier de repasser la constante à false.
Test = false

end sub

la normalement ça devrait fonctionner

Malheureusement, même avec ton code, toujours le même problème je ne comprend vraiment pas !

Je vous transmets le lien de téléchargement de mon fichier, peut-être qu'il sera plus simple pour vous de trouver l'erreur . (j'espère ) :

mdp : strike

Je viens d'assayer et pour moi ça fonctionne,

Effectivement, ça fonctionne, mais l'erreur s'affiche toujours.... J'ai remarqué que l'erreur apparaît maintenant à la fermeture de ma dernière Userform nommé "Récap"... je pense que la commande "Climatisation.show" de ma Userform " CHnégative" donc celle qui s'affiche avant la userform " Climatisation" rentre en conflit car l'ouverture de ma Userform "Climatisation" ne peut pas ce faire.... enfin je ne sais pas mais en tout cas seul la ligne "Climatisation.show" reste surligné en jaune....

voici le code est la ligne en cause Userform "CHnégative" :

Private Sub CommandButton28_Click() ' bouton valider
'initialise la flèche verte (formulaire complété)
Feuil1.Shapes("vert5").Visible = True
Feuil1.Shapes("rouge5").Visible = False

'Sélection de la feuille de calcul (ou écrire les infos)
Sheets("Chambres négative").Activate

' Utilité des chambres froides négatives
'CH 1
Range("E4") = ComboBox821.Value
'CH 2
Range("F4") = ComboBox822.Value
'CH 3
Range("G4") = ComboBox823.Value
'CH 4
Range("H4") = ComboBox824.Value
'CH 5
Range("I4") = ComboBox825.Value
'CH 6
Range("J4") = ComboBox826.Value
'CH 7
Range("K4") = ComboBox827.Value
'CH 8
Range("L4") = ComboBox828.Value

' Largeur des chambres froides négatives
'CH 1
Range("E7") = TextBox831.Value
'CH 2
Range("F7") = TextBox832.Value
'CH 3
Range("G7") = TextBox833.Value
'CH 4
Range("H7") = TextBox834.Value
'CH 5
Range("I7") = TextBox835.Value
'CH 6
Range("J7") = TextBox836.Value
'CH 7
Range("K7") = TextBox837.Value
'CH 8
Range("L7") = TextBox838.Value

' Longueur des chambres froides négatives
'CH 1
Range("E8") = TextBox841.Value
'CH 2
Range("F8") = TextBox842.Value
'CH 3
Range("G8") = TextBox843.Value
'CH 4
Range("H8") = TextBox844.Value
'CH 5
Range("I8") = TextBox845.Value
'CH 6
Range("J8") = TextBox846.Value
'CH 7
Range("K8") = TextBox847.Value
'CH 8
Range("L8") = TextBox848.Value

' Hauteur des chambres froides négatives
'CH 1
Range("E9") = TextBox851.Value
'CH 2
Range("F9") = TextBox852.Value
'CH 3
Range("G9") = TextBox853.Value
'CH 4
Range("H9") = TextBox854.Value
'CH 5
Range("I9") = TextBox855.Value
'CH 6
Range("J9") = TextBox856.Value
'CH 7
Range("K9") = TextBox857.Value
'CH 8
Range("L9") = TextBox858.Value

' évaporateurs existants ?
'CH 1
Range("E14") = ComboBox861.Value
'CH 2
Range("F14") = ComboBox862.Value
'CH 3
Range("G14") = ComboBox863.Value
'CH 4
Range("H14") = ComboBox864.Value
'CH 5
Range("I14") = ComboBox865.Value
'CH 6
Range("J14") = ComboBox866.Value
'CH 7
Range("K14") = ComboBox867.Value
'CH 8
Range("L14") = ComboBox868.Value

' Que voulez-vous en faire ?
'CH 1
Range("E15") = ComboBox871.Value
'CH 2
Range("F15") = ComboBox872.Value
'CH 3
Range("G15") = ComboBox873.Value
'CH 4
Range("H15") = ComboBox874.Value
'CH 5
Range("I15") = ComboBox875.Value
'CH 6
Range("J15") = ComboBox876.Value
'CH 7
Range("K15") = ComboBox877.Value
'CH 8
Range("L15") = ComboBox878.Value

erreur = MsgBox("Souhaitez vous enregistrer les informations saisies ?", vbYesNo, "saisie enregistrée")
If erreur = vbYes Then
demande = MsgBox("Vous allez maintenant passer à l'étape 6/6 !", vbOKOnly, " Passage à l'étape suivante")
CHnégative.Hide ' Cette commande masque le formulaire des chambres négatives tout en sauvegardant les infos saisies
End If
test = True
Climatisation.Show
Récap.Show
End Sub

l'erreur est ici.... par contre ça marche parfaitement quand le "NON" n'est pas renseigné dans G33.... une idée ?

Merci à toi Giga ! en espérant trouver le problème

Rechercher des sujets similaires à "affichage message ouverture userform"