LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Run macro on every worksheet

I've had some helpful answers already but nothing I've tried has fully
succeeded. I can't seem to get the macro to advance to the next worksheet.

I want to put a loop around this macro so that it will be run on every
worksheet in the workbook. It is in a workbook named DATA COLLECTION and
copies sheets to another workbook named DATA STORAGE AND RETRIEVAL.

TIA

Sub Data_Mover()
Application.Run "'DATA COLLECTION.xls'!StopTimer_Collect"
Windows("DATA COLLECTION").Activate

Dim wksName As String
wksName = ActiveSheet.Name

Dim wbk As Workbook

On Error Resume Next
Set wbk = Workbooks("DATA STORAGE AND RETRIEVAL.xls")
On Error GoTo 0

If wbk Is Nothing Then
'MsgBox "Opening DATA STORAGE AND RETRIEVAL"
Set wbk = Workbooks.Open("P:\Bowling Green\QA DATA\QA DATA
COLLECTION\DATA STORAGE AND RETRIEVAL.xls")
Windows("DATA COLLECTION").Activate
End If

Application.DisplayAlerts = False 'not "are you sure prompt"
On Error Resume Next 'in case it isn't there
Workbooks("DATA STORAGE AND RETRIEVAL").Worksheets(wksName).Delete
On Error GoTo 0
Application.DisplayAlerts = True
Sheets(wksName).Select
ActiveSheet.Unprotect
Worksheets(wksName).Copy After:=Workbooks( _
"DATA STORAGE AND RETRIEVAL").Worksheets("DATA STORAGE AND
RETRIEVAL")
ActiveWindow.FreezePanes = False
Rows("11:11").Select
Selection.Insert Shift:=xlDown
Rows("10:10").Select
Selection.Copy
Rows("11:11").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Rows("10:10").Delete
Rows("1:7").Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlNoSelection
ActiveWindow.SelectedSheets.Visible = False
Windows("DATA COLLECTION").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells

Application.Run "'DATA COLLECTION.xls'!StartTimer_Collect"
End Sub
--
n00b lookn for a handout :)
 
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
Macro to name worksheet tabs using a cell within the worksheet? Jennifer Excel Discussion (Misc queries) 4 November 6th 12 05:03 PM
error with macro to name new worksheet with cell from old worksheet Moon Excel Programming 4 November 14th 05 07:13 AM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM
Record Worksheet Content as Macro and Execute from another Worksheet David McRitchie[_2_] Excel Programming 2 July 23rd 03 09:43 AM


All times are GMT +1. The time now is 10:09 AM.

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"