Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default another combobox question

is there a way to retrieve the row number, when selecting a value from
rowsource dropdown in a combobox?

--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox Question jlclyde Excel Discussion (Misc queries) 2 August 27th 09 09:31 PM
Combobox Question scrabtree[_2_] Excel Programming 1 October 7th 04 07:48 PM
ComboBox Question Kevin Excel Programming 1 December 7th 03 04:54 PM
VB question on ComboBox neeas Excel Programming 1 November 14th 03 09:54 PM
ComboBox Question Terry Detrie Excel Programming 2 October 18th 03 02:55 PM


All times are GMT +1. The time now is 01:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"