![]() |
another combobox question
is there a way to retrieve the row number, when selecting a value from
rowsource dropdown in a combobox? -- Gary |
another combobox question
If you know what item you are retrieving and which row it relates to in
your overall list you can use the ComboBoxes ListIndex property. Say you have four names in your list. The first name in the combobox would have a ListIndex value of 0. So if you wanted to find out what row the name was in, you would just add 1 if the name was in row 1. If you are unsure how that will work then copy this code and all should become obvious. Just remember to substitute the name of your ComboBox for CboNames. Private Sub CboNames_Change() MsgBox " The item " & CboNames.Text & ", corresponds to " & _ "a ListIndex value of: " & CboNames.ListIndex End Sub |
another combobox question
i think that'll work, thanks mark
-- Gary "Mark" wrote in message oups.com... If you know what item you are retrieving and which row it relates to in your overall list you can use the ComboBoxes ListIndex property. Say you have four names in your list. The first name in the combobox would have a ListIndex value of 0. So if you wanted to find out what row the name was in, you would just add 1 if the name was in row 1. If you are unsure how that will work then copy this code and all should become obvious. Just remember to substitute the name of your ComboBox for CboNames. Private Sub CboNames_Change() MsgBox " The item " & CboNames.Text & ", corresponds to " & _ "a ListIndex value of: " & CboNames.ListIndex End Sub |
another combobox question
Something like this seemed to work ok:
Option Explicit Private Sub CommandButton1_Click() If Me.ComboBox1.ListIndex < 0 Then Beep Exit Sub End If With Me.ComboBox1 MsgBox Application.Range(.RowSource).Row + .ListIndex End With End Sub Private Sub UserForm_Initialize() Dim myRng As Range 'just grab some data somewhere Set myRng = Worksheets("sheet2").Range("d7:d19") With Me.ComboBox1 .RowSource = myRng.Address(external:=True) End With End Sub Gary Keramidas wrote: is there a way to retrieve the row number, when selecting a value from rowsource dropdown in a combobox? -- Gary -- Dave Peterson |
All times are GMT +1. The time now is 03:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com