troubleshooting Question

Excel VBA: clear tables activesheets /all sheets

Avatar of Luis Diaz
Luis Diaz asked on
VBAMicrosoft ExcelMicrosoft Office
5 Comments1 Solution32 ViewsLast Modified:
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.

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

Open in new window


If you have questions, please contact me.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros