我在Excel中有一个数据表。我想从表(Active_Accessions)的第一列中选择值(数字),这些值与第二列中的名称在同一行中。名称与ComboBox(cmbxLatinName)中的名称匹配。然后,所有这些操作的结果应该将第1列中的选定数字列表添加到不同的ComboBox(cmbxSourceAcc)中。
这段代码看起来不错,除了Datarw
,我不能Dim
了。我知道有一种方法可以直接进入ComboBox,但这太复杂了,所以我打算将结果写入表的第三列,我知道如何将它们拉入ComboBox。
'Match source accession to its sub-accession
Public Function GetSourceAcc()
Dim Tbl As ListObject
Dim r As Long
Dim Datarw As
Set Tbl = Sheet5.ListObjects("Active_Accessions")
r = 1
For Each Datarw In Tbl.ListRows
If Datarw.ListColumns(2).DataBodyRange = Me.cmbxLatinName.Value Then
Tbl.ListColumns(3).Offset(r, 0) = Tbl.ListColumns(1).Value
r = r + 1
End If
Next
GetSourceAcc = Sheet5.ListObjects("Active_Accessions").ListColumns(3).DataBodyRange.Value
Let Me.cmbxSourceAcc.List = GetSourceAcc
Me.cmbxSourceAcc.ListIndex = 0
End Function
1条答案
按热度按时间nzk0hqpo1#
在组合框中填充匹配项