#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Macro

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Macro

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

"Beep Beep" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macro

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
--
HTH...

Jim Thomlinson


"Beep Beep" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Macro

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

"Jim Thomlinson" wrote:

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
--
HTH...

Jim Thomlinson


"Beep Beep" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macro

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
--
HTH...

Jim Thomlinson


"Beep Beep" wrote:

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

"Jim Thomlinson" wrote:

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
--
HTH...

Jim Thomlinson


"Beep Beep" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 07:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"