Since Excel 2010 I'm using a lot of tables within Excel. For example, I have a table "tabWorkers" with 3 columns: "ID", "Firstname", "Lastname".
I already found out I can refer to a table in VBA using [].
For example:
Dim row As Range
For Each row In [tabWorkers].Rows
MsgBox (row.Columns(2).Value)
Next
This will give me the Firstname of every row which works great. But I want to make it more dynamic by using the name of it's column like this:
Dim row As Range
For Each row In [tabWorkers].Rows
MsgBox (row.Columns("Firstname").Value)
Next
Of course I could make some kind of lookup that binds the column index '2' to a var like FirstnameIndex, but I want the correct syntax. I'm sure it's possible but just not really documented (like with [tabWorkers].Rows)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…