ComboBox OLEObjects erreur
Bonjour,
J'au plusieurs UserForms et 2 ComboBox
Lors de la création du 2ème UserForm, le ComboBox est nommé 1.
J'e l'ai renommé et changé le nom du ComboBox dans les différents codes :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Private Sub ComboBox2_Change()
Application.ScreenUpdating = False
Dim Plage As Range
Dim Cel As Range
Set Plage = [B3:B900]
For Each Cel In Plage
If Cel.Value = ComboBox2.Value Then
Rows(Cel.Row).Hidden = False
Else
Rows(Cel.Row).Hidden = True
End If
Next
Application.ScreenUpdating = True
End Sub |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Private Sub Workbook_Open()
UserForm2.Show
Dim dataRange As Range
Dim cell As Range
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Interventions techniques")
Set dataRange = ws.Range("B3", ws.Range("B" & ws.Rows.Count).End(xlUp))
With ws.OLEObjects("ComboBox2").Object
.Clear
For Each cell In dataRange
If Not IsEmpty(cell.Value) And Not IsInArray(.List, cell.Value) Then
.AddItem cell.Value
End If
Next cell
End With
End Sub |
Message d'erreur :
Code:
With ws.OLEObjects("ComboBox2").Object
.Clear
Si je mets une liste déroulante sur la feuille, pas de problème mais je souhaiterais passer par un UserForm (j'en ai 1 avec plusieurs boutons pour différents recherches).
Des idées ?
Bonne journée.
Merci