Luis Diaz
asked on
Excel VBA: clear tables activesheets /all sheets
Hello experts,
Following procedure allows me to clear range of tables in activesheet. I would like to have a modulated approach with InpuBox:
If you want to clear tables on activesheet please enter S. If you want to clear all tables of worksheets of activeworkbook please select enter ALL.
If you have questions, please contact me.
Following procedure allows me to clear range of tables in activesheet. I would like to have a modulated approach with InpuBox:
If you want to clear tables on activesheet please enter S. If you want to clear all tables of worksheets of activeworkbook please select enter ALL.
Sub Clear_Format_Table()
Dim WS As Worksheet, oTbl As ListObject
On Error GoTo Error_Routine
Set oWS = Application.ActiveSheet
With oWS
'Format table
For Each oTbl In .ListObjects
oTbl.TableStyle = ""
Next oTbl
'Format range
.Cells.ClearFormats
End With
Exit Sub
Error_Routine:
MsgBox Err.Description, vbExclamation, "Something went wrong!"
End Sub
If you have questions, please contact me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Possible to have the same approach but instead of clearing the format of table clearing the format of sheet?
I believe that part was already handled?
With oWS
'Format table
For Each oTbl In .ListObjects
oTbl.TableStyle = ""
Next oTbl
'Format range
.Cells.ClearFormats
End With
ASKER
Noted. Thank you very much. I will test it and let you know.
ASKER
Tested and it works! Thank you again for this useful procedure!
ASKER
Thank you for your help?