Macro to clear particular rows and columns in multiple worksheets

I am looking for a macro that clears fields in particular tabs in a workbook. I would like to clear from A2 to M2 all the way down (all data within this range). I want to set this to a command button so it clears these fields in the 'Import', 'Current', and 'Closed' tabs. There are formulas in columns N, O, and P within these tabs but that macro shouldn't clear these. Lastly, on the 'Table of Content' tab, where it is labeled "<Customer> Carelog", if it can replace whatever the customer may be back to say "<Customer> Carelog", that would complete this macro (necessary to restart report to new for user).
DSE-Carelog-Report.xlsm
AckeemKAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roy CoxGroup Finance ManagerCommented:
Why don't you use Excel Data tables then you won't need to need to have unused Formulas in the sheets. The coding would also be simpler.
There's no data in Columns L & M is this a mistake?

Option Explicit
Sub Cleardata()
    Dim sht As Worksheet

    For Each sht In ThisWorkbook.Worksheets
        Select Case sht.Name
        Case "Import", "Current", "Closed"
            With sht
                .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp)).Resize(, 13).ClearContents
            End With
        End Select
    Next sht
End Sub

Open in new window


Which cell in TOC do you want changing?
0
AckeemKAuthor Commented:
B3 is the cell on the TOC that I want to reset after clearing all the tabs.
0
Roy CoxGroup Finance ManagerCommented:
Try this

Option Explicit
Sub Cleardata()
    Dim sht As Worksheet

    For Each sht In ThisWorkbook.Worksheets
        Select Case sht.Name
        Case "Import", "Current", "Closed"
            With sht
                .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp)).Resize(, 13).ClearContents
            End With
        End Select
    Next sht
    Sheets("Table of Contents").Range("b3").Value = "<Customer> Carelog"
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

AckeemKAuthor Commented:
I noticed that it is deleting my column headers as well. Is it because I want the panes to be frozen in both the 'Current' and 'Closed' tabs? The first row and column is what I am looking to do and I think the macro clears the headers due to the frozen panes.
0
Roy CoxGroup Finance ManagerCommented:
There's no Header Column in Import. The code does not affect the header Row when I run it even with FreezePanes set
0
AckeemKAuthor Commented:
For me, when I click on the "Restart Report" button on the table of contents tab, it clears the report and the column headers in the 'Closed' and 'Current' tab. Not sure if there's a way to fix that. Even when I unfreeze the panes and click restart report, it still clears the headers but leaves it green.
0
Roy CoxGroup Finance ManagerCommented:
Attach this workbook and I'll take a look at it.
0
AckeemKAuthor Commented:
Attached is the reporting tool along with a import file to test with. Some issues occured once I combined macros within the "Import Report File(s)" button but it will still import the file into the import tab.
DSE-Carelog-Report.xlsm
emc-ticket-history-view-2015-03-31-1432-
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Spreadsheets

From novice to tech pro — start learning today.