PDA

View Full Version : Help me for ListBox ListFillRange



Magnum
03-16-2017, 09:58 AM
Hi all,

I'm looking for how to find the index of a listbox from a value knowing that it has a ListFillRange.
J'ai trouvé comment obtenir la valeur en fonction de l'index :


Evaluate("=INDEX(" & Worksheets(pFeuille).Shapes(pNomListBox).OLEFormat.Object.ListFillRange & "," & Worksheets(pFeuille).Shapes(pNomListBox).OLEFormat.Object.Value & ")")

But I can not do the opposite.

Can you help me ?

_________
Magnum
mickael.pusku.com

mana
03-17-2017, 03:46 AM
Sub test()

With Worksheets(pFeuille).Shapes(pNomListBox).OLEFormat.Object
MsgBox .List(.ListIndex)
End With

End Sub


Sub test2()

With Worksheets(pFeuille).Shapes(pNomListBox).DrawingObject
MsgBox .List(.ListIndex)
End With

End Sub

Magnum
03-17-2017, 06:22 AM
Thanks mana for your response.

But when i try, i have error : Unable to read the ListIndex property of the DropDown class


_________
Magnum
mickael.pusku.com

Magnum
03-17-2017, 06:28 AM
I solved my problem with this solution:


Function ListBoxSetValue(pFeuille As String, pNomListBox As String, pValue As String)
Worksheets(pFeuille).Shapes(pNomListBox).OLEFormat.Object.Value = RetourneIndexListBox(Range(Worksheets(pFeuille).Shapes(pNomListBox).OLEForm at.Object.ListFillRange), pValue)
End Function

Function RetourneIndexListBox(plage As Range, ch As String) As Long
Application.Volatile
Dim mLigne
mLigne = 0
For Each C In plage
mLigne = mLigne + 1
If C.Value = ch Then RetourneIndexListBox = mLigne
Next
End Function

Sub test()
Call ListBoxSetValue(RH2, "SQLSERVER_VERSION", "2008")
End Sub

I did not find it simpler, but it works.

_________
Magnum
mickael.pusku.com