This sub is supposed to find the row that matches the name in the userform combobox. Then pull in data from other columns in that row. Trying to do it with structured referencing after reading the posts below but still not getting it.
How do i loop an excel 2010 table by using his name & column reference?.
Looping through all rows in a table column, Excel-VBA
Edited to change row
to row.Value
and deleted Set row
Here are a few different attempts.
I get an Object required
error with the first one at the If Intersect
line
Dim tbl As ListObject
Dim row As Range
Set tbl = ActiveSheet.ListObjects("List")
For Each row In [List[Name]].Rows
If Intersect(row.Value, tbl.ListColumns("Name").Range).Value = (Me.cbName) Then
With tbl.DataBodyRange
Me.tbItem.Value = Intersect(row.Value, .ListColumns("Item").Range).Value
'rest of code
End With
End If
Next
Another try
I get an Invalid procedure call or argument
error at the If Range
line
Dim tbl As ListObject
Dim row As Range
Set tbl = ActiveSheet.ListObjects("List")
For Each row In [List[Name]].Rows
If Range("List[Name]")(row.Value) = Me.cbName Then
Me.tbItem.Value = Range("List[Item]")(row.Value).Value
'rest of code
End If
Next