UserForm non reconnu / Initialisation Userform / Combobox
Bonjour à tous,
Après une journée à essayer de résoudre ce souci, je finis par venir vous demander de l'aide !
Un premier userform avec 2 boutons propose :
- Extension --> renvoie à un code qui fonctionne
- Nouvelle FS --> renvoie à un autre code qui plante
Lorsque le bouton Nouvelle FS est sélectionné, un second userform (UF_NOUVELLE_GAMME) s'ouvre et demande des valeurs via des "Zones de Texte". Là, pas de souci cela fonctionne toujours.
Après avoir rempli ces zones de texte, une troisième userform (UF_NOUVELLE_GAMME_EBAUCHE) est sensée s'ouvrir, contenant des Comboboxs. Dès que le code arrive à la ligne où cette Userform est nommée, une erreur apparaît :
Citation:
"Erreur d'exécution '91' : Variable objet ou variable de bloc With non définie"
La 3ème Userform est pourtant déclarée au début, et une initialisation est réalisée ... Je vous joins mes codes, si vous avez des idées...
Merci !!
Code:
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
| Sub UF_NOUVELLE_FS_Click()
Dim NOUV_REF As String
Dim NOUV_DESIGNATION As String
Dim NOUV_INDICE As String
Dim NOUV_PROFIL As String
Dim NOUV_NUANCE As String
Dim UF_NOUVELLE_GAMME_EBAUCHE As UserForm
'Cacher Userform UF_NOUVELLE_FS
Me.Hide
' Vider les cases
UF_NOUVELLE_GAMME.TB_NOUV_REF = ""
UF_NOUVELLE_GAMME.TB_NOUV_DESIGN = ""
UF_NOUVELLE_GAMME.TB_NOUV_INDICE = ""
UF_NOUVELLE_GAMME.TB_NOUV_PROFIL = ""
UF_NOUVELLE_GAMME.TB_NOUV_NUANCE = ""
UF_NOUVELLE_GAMME.TB_NOUV_DESIGN.SetFocus
UF_NOUVELLE_GAMME.TB_NOUV_INDICE.SetFocus
UF_NOUVELLE_GAMME.TB_NOUV_PROFIL.SetFocus
UF_NOUVELLE_GAMME.TB_NOUV_NUANCE.SetFocus
UF_NOUVELLE_GAMME.TB_NOUV_REF.SetFocus
'Faire apparaître l'Userform UF_NOUVELLE_GAMME
UF_NOUVELLE_GAMME.Show
NOUV_REF = CStr(UF_NOUVELLE_GAMME.TB_NOUV_REF.Value)
NOUV_DESIGNATION = CStr(UF_NOUVELLE_GAMME.TB_NOUV_DESIGN.Value)
NOUV_INDICE = CStr(UF_NOUVELLE_GAMME.TB_NOUV_INDICE.Value)
NOUV_PROFIL = CStr(UF_NOUVELLE_GAMME.TB_NOUV_PROFIL.Value)
NOUV_NUANCE = CStr(UF_NOUVELLE_GAMME.TB_NOUV_NUANCE.Value)
'Convertir en majuscules les valeurs entrées
NOUV_REF = UCase(NOUV_REF)
NOUV_DESIGNATION = UCase(NOUV_DESIGNATION)
NOUV_INDICE = UCase(NOUV_INDICE)
NOUV_PROFIL = UCase(NOUV_PROFIL)
NOUV_NUANCE = UCase(NOUV_NUANCE)
'Ouvrir workbook
Workbooks.Open "C:\2020_donnees.xls"
Worksheets("donnees").Activate
Set SelectionCell = Application.InputBox(prompt:="Sélectionner la zone pour insérer la nouvelle gamme", Type:=8)
'Insérer 3 lignes vides en dessous d'une référence
LIGNE = SelectionCell.Row
Rows(LIGNE).Offset(Rows(LIGNE).Rows.Count + 1, 0).EntireRow.Insert Shift:=xlDown
Rows(LIGNE).Offset(Rows(LIGNE).Rows.Count + 1, 0).EntireRow.Insert Shift:=xlDown
Cells(LIGNE, ("A:A")).Select
ActiveCell.Offset(2, 0).EntireRow.Select
Selection.Interior.ColorIndex = 4
NomGamme = InputBox("Entrer le nom de la gamme")
Cells(ActiveCell.Row, 1).Select
ActiveCell.Value = NomGamme
ActiveCell.HorizontalAlignment = xlLeft
Cells(ActiveCell.Row, 1).Select
ActiveCell.Offset(Rows(LIGNE).Rows.Count + 1, 0).EntireRow.Insert Shift:=xlDown
ActiveCell.Offset(Rows(LIGNE).Rows.Count + 1, 0).EntireRow.Insert Shift:=xlDown
'Remplir la ligne en-dessous
ActiveCell.Offset(1, 0).Activate
ActiveCell.Value = NOUV_REF
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = NOUV_DESIGNATION
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = NOUV_INDICE
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = NOUV_PROFIL
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = NOUV_NUANCE
'EBAUCHE, cela plante à partir de là
' Vider les cases
UF_NOUVELLE_GAMME_EBAUCHE.TB_NOUV_IND_EB = ""
UF_NOUVELLE_GAMME_EBAUCHE.TB_NOUV_DATE_EB = ""
UF_NOUVELLE_GAMME_EBAUCHE.TB_OP10E = ""
UF_NOUVELLE_GAMME_EBAUCHE.TB_NOUV_IND_EB.SetFocus
UF_NOUVELLE_GAMME_EBAUCHE.TB_NOUV_DATE_EB.SetFocus
UF_NOUVELLE_GAMME_EBAUCHE.TB_OP10E.SetFocus
'Faire apparaître la fenêtre pour demander les valeurs de lancement d'OF
UF_NOUVELLE_GAMME_EBAUCHE.Show
NOUV_IND_EB = CStr(UF_NOUVELLE_GAMME_EBAUCHE.TB_NOUV_IND_EB.Value)
NOUV_DATE_EB = CDate(UF_NOUVELLE_GAMME_EBAUCHE.TB_NOUV_DATE_EB.Value)
NOUV_OP10E = CStr(UF_NOUVELLE_GAMME_EBAUCHE.TB_OP10E.Value)
End Sub |
L'initialisation de la Combobox "TB_OP10E" est :
Code:
1 2 3 4 5 6 7 8
| Private Sub UserForm_Initialize()
Worksheets("OP_SERVICES").Activate
For i = 2 To 34
Me.TB_OP10E.AddItem Cells(i, 1)
Next i
End Sub |
Merci encore pour votre aide !!