Hi all, I have been reading the internet all day trying to figure out how to properly reference tables and i have tried everything i could find but so far am at a loss...
I've recently begun using Power Query a lot, so I figured I'd better learn how to refer to tables in VBA... it seems like it should be super simple and intuitive, and maybe for others it is... but I am at my wits end trying to understand how to correctly loop through a table and assign the value of the cell in the active row of the desired column. God I hope someone out there can put this into words that will make sense... I swear i've tried every combination of every post that comes up in the first 5 google search pages for every search combination of VBA, Table, Variable, Excel, Syntax, Loop, Reference, etc....
myTable
[TABLE="width: 500"]
<tbody>[TR]
[TD]Primary ID (PrID variable)[/TD]
[TD]Name[/TD]
[/TR]
[TR]
[TD]1564654[/TD]
[TD]Jim[/TD]
[/TR]
[TR]
[TD]7578445[/TD]
[TD]Jane[/TD]
[/TR]
[TR]
[TD]1983587[/TD]
[TD]Elvis[/TD]
[/TR]
</tbody>[/TABLE]
So first loop the variable PrID would be 1564654, 2nd iteration would be 7578445, 3rd would be 1983587 and so on...
Eventually I'd like to be able to use the variable for things like
etc...
Please, please, please put me out of my misery!
Thanks in advance
I've recently begun using Power Query a lot, so I figured I'd better learn how to refer to tables in VBA... it seems like it should be super simple and intuitive, and maybe for others it is... but I am at my wits end trying to understand how to correctly loop through a table and assign the value of the cell in the active row of the desired column. God I hope someone out there can put this into words that will make sense... I swear i've tried every combination of every post that comes up in the first 5 google search pages for every search combination of VBA, Table, Variable, Excel, Syntax, Loop, Reference, etc....
myTable
[TABLE="width: 500"]
<tbody>[TR]
[TD]Primary ID (PrID variable)[/TD]
[TD]Name[/TD]
[/TR]
[TR]
[TD]1564654[/TD]
[TD]Jim[/TD]
[/TR]
[TR]
[TD]7578445[/TD]
[TD]Jane[/TD]
[/TR]
[TR]
[TD]1983587[/TD]
[TD]Elvis[/TD]
[/TR]
</tbody>[/TABLE]
Code:
Sub Test()
Dim myTable As ListObject
Dim Master As Workbook
Dim Listsht As Worksheets
Set Master = ThisWorkbook
Set Listsht = Master.Sheets("Summary List")
Set myTable = Listsht.ListObjects("Summary_Listing")
For Each rw In myTable.ListRows '//Loop through each row\\
PrID = ???????????????? I have tried everything here and keep getting object missmatch or some other error, wrong number of arguments, invalid property assignment... the list goes on...
shouldn't it be something simple like[INDENT]PrID = myTable([@[Primary ID]]) or
PrID = myTable("[Primary ID](rw)")
[/INDENT]
Next rw
End Sub
So first loop the variable PrID would be 1564654, 2nd iteration would be 7578445, 3rd would be 1983587 and so on...
Eventually I'd like to be able to use the variable for things like
Code:
ApplicationFunction.Match(PrID, Master.sheets("sheet1").Range("A:A"), 0)
Please, please, please put me out of my misery!
Thanks in advance