如何使用结构化引用遍历命名行和列

时间:2017-11-23 08:24:05

标签: excel vba excel-vba

此子应该找到与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

0 个答案:

没有答案