Runtime error 91 "Object variable or With block variable not set"

  • Thread starter Thread starter Sanjay NG
  • Start date Start date
S

Sanjay NG

Guest
Dear all,

My requirement is to clear the content of all the table from entire workbook. Each sheet has multiple tables and I have multiple sheets .

I have written the below code

Sub cleardata()

Dim tbl As ListObject
Dim sht As Worksheet

For Each sht In ThisWorkbook.Worksheets

If sht.Name <> "Contents" And sht.Name <> "Cover Page" Then
For Each tbl In sht.ListObjects

tbl.DataBodyRange.ClearContents

Next tbl
End If
Next sht

End Sub

Any advice or help will be appreciated.

Continue reading...
 
Back
Top