Hi
Having created a load of test data I would now like to loop through all tables in the workbook (eventually, I want to create an array of the specific named tables, but let's walk first), deleting the data.
I can now loop through the tables, debug printing the names - tick
But I do not appear to be able to select a table cell, which then will allow me to run the delete routine.
Any help here gratefully received and I have resisted the temptation to come begging for two days .. yes I know.
Sub loopSheets()
Dim tbl As ListObject
Dim ws As Worksheet
Dim i As Integer
For Each ws In ActiveWorkbook.Worksheets ' use activeworkbook NOT this workbook for some reason
For Each tbl In ws.ListObjects
For i = 1 To 5 ' doubt there are more than 5 tables on a sheet although to have this 'open' would be great
Set tbl = ActiveSheet.ListObjects(i) ' I thought this was how to move through the tables per sheet
With tbl ' not sure if this is where it is breaking
ListObject.Range.Rows(2).Columns(1).Select
If Not ActiveCell.ListObject Is Nothing Then
ActiveCell.ListObject.DataBodyRange.Rows.ClearCont ents
End If
Debug.Print tbl.Name
End With
Debug.Print i
Next i
Next tbl
Debug.Print ws.Name
Next ws
End Sub