Refer to Excel cell in Table by header name and row number

后端 未结 7 1477
孤独总比滥情好
孤独总比滥情好 2020-12-23 14:58

I\'m trying to refer to a cell in an excel table by using the table header name and the row number using VBA.

How can I do this?

7条回答
  •  时光说笑
    2020-12-23 15:19

    In your example, something like this:

    Dim tb As ListObject
    'assumes Table is the first one on the ActiveSheet
    Set tb = ActiveSheet.ListObjects(1)
    MsgBox tb.DataBodyRange.Cells(2, tb.ListColumns("header4").Index)
    

提交回复
热议问题