Hello,
I am tying to clear the contents of a table so that when I paste in new values the data will still have the same table name. What I have so far requires me to have clicked on the table so that 'Activecell' Works. I would like it so that the vba selects the table without the user having to.
Thanks
Tripp
I am tying to clear the contents of a table so that when I paste in new values the data will still have the same table name. What I have so far requires me to have clicked on the table so that 'Activecell' Works. I would like it so that the vba selects the table without the user having to.
Code:
Sub ClearTable()
Application.ScreenUpdating = False
'Clears the table contents
If Not ActiveCell.ListObject Is Nothing Then
ActiveCell.ListObject.DataBodyRange.Rows.ClearContents
End If
'Shrinks the Table to one blank row
If Not ActiveCell.ListObject Is Nothing Then
ActiveCell.ListObject.DataBodyRange.Delete
End If
Application.ScreenUpdating = True
End Sub
Thanks
Tripp