Macro

B

Beep Beep

I have an Excel workbook with 15 worksheets in it that each week I need to
zero out the data from four (4) columns that are next to each other to get
ready for the next week. I would like a macro to do either zero out one and
then jump to the next or do them all at one time.

Thanks
Beep Beep
 
M

Mike

This will clear out Columns A thru D

Sub clearWorksheetLoop()
Dim WS_Count As Integer
Dim i As Integer
WS_Count = _
ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
ActiveWorkbook.Worksheets(i) _
.Columns("A:D").ClearContents
Next i
End Sub
 
J

Jim Thomlinson

As a macro you need to do it one sheet at a time. Did you need all 15 sheets
or are some excluded? did you need the whole column or just parts of the
column.

This will go through all sheets and clear out a range of cells

sub ClearStuff()
dim wks as worksheet

for each wks in worksheets
with wks
.range(.range("B2"), .cells(rows.count, "E")).clearcontents
end with
next wks
end sub
 
B

Beep Beep

Jim yes I have more sheets then the 15 I mentioned. There are only 15 that I
need to change on a weekly basis. I guess I would have to have the name of
the tab's in the macro or as you suggested one at a time
 
J

Jim Thomlinson

In that case try this

sub ClearStuff()
dim wks as worksheet

for each wks in worksheets
with wks
select case .name
Case "Sheets", "I", "Don't", "Want", "Cleared" 'sheet names
Case Else
.range(.range("B2"), .cells(rows.count, "E")).clearcontents
End Select
end with
next wks
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Macro required 4
Do Until 4
VBA set thick borders around non empty cells in range 0
Excel 2013 Merge Data 2
Run-time error 9 6
Macro to delete rows 3
Sheet name changing dilemma 2
Apply macro to all worksheets 15

Top