B
b.sounds
Guest
Salut le forum,
J'ai essayé d'adapter une formule de Pascal76 pour une recherche de données sur un classeur excel.
Ce code me permet d'obtenir une liste dans une ComboBox.
Voilà le code:
Dim WSDonnees As Worksheet
Dim Plage As Range
Dim PlageNom As String
Dim A As Long
Private Sub UserForm1_Initialize()
End Sub
Private Sub ComboBox1_Change()
txtNom = ComboBox1.List(ComboBox1.ListIndex, 1)
txtPrénom = ComboBox1.List(ComboBox1.ListIndex, 2)
txtSociété = ComboBox1.List(ComboBox1.ListIndex, 3)
End Sub
Private Sub CommandButton1_Click()
Set WSDonnees = Workbooks("\\Samy\gestion stock\Son\emprunteurs.xls").Worksheets(1)
With WSDonnees
PlageImmo = .Range("A2:E" & .Range("A65536").End(xlUp).Row).Address
End With
UserForm1.ComboBox1.RowSource = ("U:\Samy\gestion stock\Son\emprunteurs.xls!") & PlageNom
With Sheets("Fiche de prêt")
.Range("B7").Value = ComboBox1.Value
.Range("D7").Value = TextBox2.Value
.Range("F7").Value = TextBox3.Value
.Range("I7").Value = TextBox4.Value
End With
Unload Me
UserForm2.Show
End Sub
Seulement ça coince au niveau de SetWSDonnees: il ne reconnait pas le chemin d'accès. Le fichier en question se situe sur le serveur.
Comment faire?
Merci à tous.
J'ai essayé d'adapter une formule de Pascal76 pour une recherche de données sur un classeur excel.
Ce code me permet d'obtenir une liste dans une ComboBox.
Voilà le code:
Dim WSDonnees As Worksheet
Dim Plage As Range
Dim PlageNom As String
Dim A As Long
Private Sub UserForm1_Initialize()
End Sub
Private Sub ComboBox1_Change()
txtNom = ComboBox1.List(ComboBox1.ListIndex, 1)
txtPrénom = ComboBox1.List(ComboBox1.ListIndex, 2)
txtSociété = ComboBox1.List(ComboBox1.ListIndex, 3)
End Sub
Private Sub CommandButton1_Click()
Set WSDonnees = Workbooks("\\Samy\gestion stock\Son\emprunteurs.xls").Worksheets(1)
With WSDonnees
PlageImmo = .Range("A2:E" & .Range("A65536").End(xlUp).Row).Address
End With
UserForm1.ComboBox1.RowSource = ("U:\Samy\gestion stock\Son\emprunteurs.xls!") & PlageNom
With Sheets("Fiche de prêt")
.Range("B7").Value = ComboBox1.Value
.Range("D7").Value = TextBox2.Value
.Range("F7").Value = TextBox3.Value
.Range("I7").Value = TextBox4.Value
End With
Unload Me
UserForm2.Show
End Sub
Seulement ça coince au niveau de SetWSDonnees: il ne reconnait pas le chemin d'accès. Le fichier en question se situe sur le serveur.
Comment faire?
Merci à tous.