How do I loop through the values in a combocox?

dogdays

Active Member
Joined
Apr 28, 2008
Messages
431
I have a combobox with three columns of data, I wish to loop through each row to find a particular value in the first column. I tried the following:
Rich (BB code):
Private Sub Form_Current()
    Dim iIndex As Integer
    
    For iIndex = 0 To Me.cboRelationshipTypes.ListCount - 1
        If Me.cboRelationshipTypes(iIndex).Column(0) = 7 Then
            Me.cboRelationshipTypes.ListIndex = iIndex
            Exit Sub
        End If
    Next iIndex
End Sub

The line in blue gives me a Type Mismatch error. Any help would be appreciated.

Jack
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

jackd

Well-known Member
Joined
Oct 19, 2006
Messages
1,299
Office Version
  1. 365
What are you trying to do? Forget Access for the moment, just in plain english tell us the issue. Maybe there are other approaches.
 

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,793
Office Version
  1. 2019
Platform
  1. Windows
Seems like you can just use the value:

Me.ComboBox1.Value = 7

Then you're on that row.

As above --> what's the ultimate aim...
 

dogdays

Active Member
Joined
Apr 28, 2008
Messages
431
I was trying to validate data in an existing table. Accomplished in a different way. Thanks for the comments.

Jack
 

Watch MrExcel Video

Forum statistics

Threads
1,122,658
Messages
5,597,403
Members
414,142
Latest member
Banyangt

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
Top