VBA Clear Table Content in Excel

VBA Clear Table Content

VBA Clear Table Content in Excel. This means clearing or deleting or removing data from the table in Excel using VBA. Here we use the ListObjects collection and ClearContents property to delete or clear data. In this tutorial let us learn the example and step by step instructions to clear content from the table.

Example to VBA Delete Table Content in Excel

Let us see the example to clear content or data from the table of data body range. The sheet name defined as ‘Table‘. And we use table name as ‘MyDynamicTable‘. You can change these two as per your requirement. Where ClearContents property is used to clear data from the table.

'VBA Clear Table Content
Sub VBAF1_Clear_Table_Content()
    
    'Definf Sheet and table name
     With Sheets("Table").ListObjects("MyDynamicTable")
        
        'Check If any data exists in the table
        If Not .DataBodyRange Is Nothing Then
            'Clear Content from the table
            .DataBodyRange.ClearContents
        End If
        
    End With
    
End Sub

Output: Here is the following output screenshot of above example macro code.

VBA Clear Table Content in Excel

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays in Excel VBA Tables and ListObjects

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog

Leave a Comment