Can a variable be assigned to a table based on the active sheet? I have a workbook with multiple tabs which contain unique tables in each tab (one table per tab). I have a macro that will clear the contents of a table, but currently, I have to use the specific name of the table I want to clear in the macro. I want to have a button (text box with assigned macro) on each tab that allows me to clear the contents of the table of the active sheet, but I do not know how to assign a variable to the table on the active sheet. I know I can have a separate macro referencing the each table, but I want the macro to adjust for the active sheet. Below is the code I'm currently using:
Sub Clear_Data_ChangeMGT()
'
' Clear data from ChangeMGT_tbl table
'
'
Range("ChangeMGT_tbl[[Task Order]:[Department Interdependency]]").ClearContents
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
Sub Clear_Data_ChangeMGT()
'
' Clear data from ChangeMGT_tbl table
'
'
Range("ChangeMGT_tbl[[Task Order]:[Department Interdependency]]").ClearContents
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub