Sub ClearTableColumn(col_Header As String)
ActiveSheet.ListObjects(1).ListColumns(col_Header).DataBodyRange.ClearContents
End Sub
Sub test()
ClearTableColumn "qwr"
End Sub
Sub test()
ClearTableColumn "abc def"
End Sub
You have a code something like this
Code:Sub ClearTableColumn(col_Header As String) ActiveSheet.ListObjects(1).ListColumns(col_Header).DataBodyRange.ClearContents End Sub
Then when you want to clear a column you use, say
.. and next time it might beCode:Sub test() ClearTableColumn "qwr" End Sub
Code:Sub test() ClearTableColumn "abc def" End Sub
You are welcome.This works. Thanks!
Sub test()
Dim ColsToClear As Variant, itm As Variant
ColsToClear = Array("qwr", "abc def", "Date")
For Each itm In ColsToClear
ClearTableColumn CStr(itm)
Next itm
End Sub
Sub test2()
Dim ColsToClear As Variant, itm As Variant
ColsToClear = Array("qwr", "abc def", "Date")
For Each itm In ColsToClear
ActiveSheet.ListObjects(1).ListColumns(itm).DataBodyRange.ClearContents
Next itm
End Sub
.. and it didn't have to be in a separate routine, that was just one way of doing it. You could also have a structure like this
Code:Sub test2() Dim ColsToClear As Variant, itm As Variant ColsToClear = Array("qwr", "abc def", "Date") For Each itm In ColsToClear ActiveSheet.ListObjects(1).ListColumns(itm).DataBodyRange.ClearContents Next itm End Sub