trouver une ligne # de l'élément sélectionné dans la listbox vba

Comment puis-je trouver la ligne # de l'élément sélectionné dans la listbox?

droit maintenant, j'ai un sub que toutes les entrées de l'élément trouvé dans la zone de liste, voir ci-dessous

Sub findnext()
Dim Name As String
Dim f As Range
Dim ws As Worksheet
Dim s As Integer
Dim findnext As Range
Set ws = ThisWorkbook.Worksheets("Master")
Name = surname.Value
ListBox1.Clear
Set f = Range("A:A").Find(what:=Name, LookIn:=xlValues)
Set findnext = f
Do
Debug.Print findnext.Address
Set findnext = Range("A:A").findnext(findnext)
ListBox1.AddItem findnext.Value
ListBox1.List(ListBox1.ListCount - 1, 1) = ws.Cells(findnext.Row, xFirstName).Value
ListBox1.List(ListBox1.ListCount - 1, 2) = ws.Cells(findnext.Row, xTitle).Value
ListBox1.List(ListBox1.ListCount - 1, 3) = ws.Cells(findnext.Row, xProgramAreas).Value
ListBox1.List(ListBox1.ListCount - 1, 4) = ws.Cells(findnext.Row, xEmail).Value
ListBox1.List(ListBox1.ListCount - 1, 5) = ws.Cells(findnext.Row, xStakeholder).Value
ListBox1.List(ListBox1.ListCount - 1, 6) = ws.Cells(findnext.Row, xofficephone).Value
ListBox1.List(ListBox1.ListCount - 1, 7) = ws.Cells(findnext.Row, xcellphone).Value
'ListBox1.List(ListBox1.ListCount - 1, 8) = ws.Cells(findnext.Row, xFirstName).Value
Loop While findnext.Address <> f.Address
End Sub

et si l'utilisateur sélectionne l'élément dans la zone de liste, puis il va remplir les informations dans la zone de texte de l'objet userform

Sub ListBox1_Click()
surname.Value = ListBox1.List(ListBox1.ListIndex, 0)
firstname.Value = ListBox1.List(ListBox1.ListIndex, 1)
tod.Value = ListBox1.List(ListBox1.ListIndex, 2)
program.Value = ListBox1.List(ListBox1.ListIndex, 3)
email.Value = ListBox1.List(ListBox1.ListIndex, 4)
SetCheckBoxes ListBox1.List(ListBox1.ListIndex, 5)        '<<<< added
officenumber.Value = ListBox1.List(ListBox1.ListIndex, 6)
cellnumber.Value = ListBox1.List(ListBox1.ListIndex, 7)     
End Sub

je veux figure de ListBox1_click() comment je peux déterminer la ligne # de l'élément sélectionné dans la listbox. une fois que j'ai cela, je code un update sub où il va retrouver la ligne # de l'élément sélectionné et je vais re-saisir les informations dans les zones de texte et mettre à jour les informations de la ligne.

j'ai pensé à stocker une ligne # caché dans un feuille de calcul lorsque je ne find.. mais je ne sais pas comment relier la ligne # de la found avec ce qui a été sélectionné dans la listbox

j'espère...ce qui a du sens, si ce n'est s'il vous plaît laissez-moi savoir!

InformationsquelleAutor Doolie1106 | 2014-04-14