Select entire column in table using Excel VBA

后端 未结 2 1329
温柔的废话
温柔的废话 2020-12-05 09:07

I have a table in an excel sheet and I want to select the entire first row. Is there an easier/faster way to reference a table than the normal

 Range(\"A2\"         


        
相关标签:
2条回答
  • 2020-12-05 09:35

    With these codes you can select different parts of a table.

    Entire Table:
    ActiveSheet.ListObjects("Table1").Range.Select

    Table Header Row:
    ActiveSheet.ListObjects("Table1").HeaderRowRange.Select

    Table Data:
    ActiveSheet.ListObjects("Table1").DataBodyRange.Select

    Third Column:
    ActiveSheet.ListObjects("Table1").ListColumns(3).Range.Select

    Third Column (Data Only):
    ActiveSheet.ListObjects("Table1").ListColumns(3).DataBodyRange.Select

    Select Row 4 of Table Data:
    ActiveSheet.ListObjects("Table1").ListRows(4).Range.Select

    Select 3rd Heading:
    ActiveSheet.ListObjects("Table1").HeaderRowRange(3).Select

    Select Data point in Row 3, Column 2:
    ActiveSheet.ListObjects("Table1").DataBodyRange(3, 2).Select

    Subtotals:
    ActiveSheet.ListObjects("Table1").TotalsRowRange.Select

    For a full guide on tables see The VBA Guide To ListObject Excel Tables.

    0 讨论(0)
  • 2020-12-05 09:54

    This is the shortest way I know:

    Rows(1).Select
    

    Here you can fin some example about it.

    0 讨论(0)
提交回复
热议问题