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: 49
Default stuck in loop

Hi all,

I've altered the code for browse and protect that Dave Peterson helped me
with and now it gets stuck in a loop.

The original code looped though all workbooks in browsed for folder and then
looped through all worksheets with a for each loop.

I altered the code to do a different job. What I wanted to do was copy an
array of sheets from the workbook with the code to all the workbooks in the
folder.

Here's the bits of code
This is the end of the browse for filename code
Set myWB = Workbooks.Open(myPath & myName)
Call CopyTemplates(myWB)

Application.AutomationSecurity = AutoSecurity
On Error Resume Next

myName = Dir ' Get next entry.
If myName = "" Then
Exit Do
End If
Loop
End If
End If
Next
End Sub
This is the bit that replaced the for each unprotect
Sub CopyTemplates (myWB As Workbook)

Set myWB = ActiveWorkbook

ThisWorkbook.Worksheets(Array("Datasheet1", "Datasheet2", "Datasheet3", _
"Charts1", "Charts2", "Charts3", "Summary")).Copy _
Befo=myWB.Worksheets(1)

myWB.Close savechanges:=True

End Sub

If anyone could tell me what's missing please, I'd be more than grateful.

Thank you


--
Trish
 
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
stuck in an error loop Darla Excel Discussion (Misc queries) 1 January 8th 10 06:06 PM
stuck at a loop computers hate me Excel Programming 6 August 4th 08 02:19 PM
Stuck in a Sub Loop robzrob Excel Worksheet Functions 4 July 19th 08 11:53 PM
Stuck in a loop CWillis Excel Discussion (Misc queries) 2 June 5th 06 02:49 PM
HELP - Stuck in loop gti_jobert[_92_] Excel Programming 3 April 27th 06 01:41 PM


All times are GMT +1. The time now is 07:17 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"