Select entire column in table using Excel VBA
With these codes you can select different parts of the table.
Whole table: ActiveSheet.ListObjects("Table1").Range.Select
Table Header Title: 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 the table data: ActiveSheet.ListObjects("Table1").ListRows(4).Range.Select
Select the third heading: ActiveSheet.ListObjects("Table1").HeaderRowRange(3).Select
Select the data item in row 3, column 2: ActiveSheet.ListObjects("Table1").DataBodyRange(3, 2).Select
subtotals: ActiveSheet.ListObjects("Table1").TotalsRowRange.Select
For a complete guide to tables, see VBA Guide to Excel ListExject Tables .
source to share
The above seems to only work if it is an actual Excel table object. If you only have rows and columns of data with headers in a worksheet and it is not an actual Excel table object, it will not work and you have to use the following code.
We select a range from A2 (A1 is the header row of our column and we don't want to clear the header), ctrl to the right, then ctrl to down to find the last record in the sheet. We then clear the rows and columns on the sheet.
Sub clear_table()
Range("A2", Range("A2").End(xlToRight).End(xlDown).Address).Clear
End Sub
source to share