Selectionner un classeur par variable
Bonjour à tous,
Voici mon problème :
j'utilise une combo_box dans laquelle je mets les noms des classeurs excel ouverts. Comment ouvrir le classeur qui sera selectionné par l'utilisateur ?
Voilà ce que j'ai fait :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Private Sub ComboBox_Pays_Change()
Dim NomFichier As String
Dim wb As Workbook
NomFichier = ComboBox_Pays.Text
MsgBox NomFichier
Workbooks(" & nomfichier & ").Sheets(1).Select
End Sub
Private Sub UserForm_Initialize()
Dim wb As Workbook
For Each wb In Workbooks
ComboBox_Pays.AddItem wb.Name
Next wb
End Sub |
Mais je me vois retourné une erreur disant :
"l'indice n'appartient pas à la selection" (code erreur d'execution 9)
Par avance merci de votre aide,
Philippe