Obtaining row value of combo box selection

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Does anyone have any code that will give me the row value of a chosen item on a combo box?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
But what if I selected a different row each time?

Code:
ComboBox1.ListIndex + 1

would give me the same value. In the example I am working on, I have 4 rows, if I select the last row I can get the value by

Code:
strFilter = frm!cboFilter.Column(2,3)

But if I selected the third row it would be

Code:
strFilter = frm!cboFilter.Column(2,2)

What I want is

Code:
strFilter = frm!cboFilter.Column(2,x)

where the VBA code tells me the value of x i.e. the chosen row.
 
Upvote 0
A couple of options !!
Code:
Private Sub cboFilter_Change()
Dim Strfilter As String, Strg As String
With Me.cboFilter
    Strfilter = .Column(2, .ListIndex)
    Strg = .List(.ListIndex, 2)
End With
MsgBox Strfilter & vbLf & Strg

End Sub
 
Upvote 0
I get Run Time error 438 - Object doesnt support this property or method on line

Code:
Strg = .List(.ListIndex, 2)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top