Please be patient with me; I'm new to coding and am well over my head. I have an excel table with data. I want to use VBA to choose values (numbers) from the table's Active Accessions, first column, that are in the same row as names in the second column. The names correspond to those in a combination box (cmbxLatinName). The list of chosen numbers from column 1 should then be added as a result of all of this into a separate comboxbox (cmbxSourceAcc). This current code, which I spent hours searching for to understand and utilise, sounds nice, but I can't get the Datarw right; I can't 'dim' it. I was going to write the results into the third column of the table since I knew how to pull them into the combobox even though there is a way to get directly into the combo box that is too hard for me. I'm sure my project and code are ugly, but I'm learning and they do provide the outcomes when I can get them to function.
'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
GetSourceAcc = Sheet5.ListObjects("Active_Accessions").ListColumns(3).DataBodyRange.Value
Let Me.cmbxSourceAcc.List = GetSourceAcc
Me.cmbxSourceAcc.ListIndex = 0
The line Dim Datarw As... I can't figure out the correct way to dim it so it breaks/debugs too for or if depending on how I dim it.