Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
stuck in an error loop | Excel Discussion (Misc queries) | |||
stuck at a loop | Excel Programming | |||
Stuck in a Sub Loop | Excel Worksheet Functions | |||
Stuck in a loop | Excel Discussion (Misc queries) | |||
HELP - Stuck in loop | Excel Programming |