此子应该找到与userform组合框中的名称匹配的行。然后从该行的其他列中提取数据。在阅读下面的帖子但仍然没有得到它之后,尝试使用结构化参考。
How do i loop an excel 2010 table by using his name & column reference?
Looping through all rows in a table column, Excel-VBA
已修改为row
更改为row.Value
并已删除Set row
以下是一些不同的尝试
我在Object required
行
If Intersect
错误
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
另一个尝试
我在Invalid procedure call or argument
行
If Range
错误
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