excel - Copy worksheet macro stops doing anything when the workbook hits 50 worksheets -


I have a workbook that has many cover sheets and then a bunch of rear sheets that have some graphs.

The macro is originally used to bite fast with a .

Copying worksheet class failed error I finally found how to fix it.

The problem is that, with my updated version I have endless problems; Mostly it continues happily, but does not actually copy anything after a while. This part of making this happy is that something in the update logic sets x = y, if x is nothing at all. s, which (as far as I know) will work with only suppressing errors, that's what happened to me. But on the other hand, it stops copied sheets after 50 sheets, and does not give any explanation (although this may be the wrong location of error on Goto ).

Does anybody know that I really need to fix all the sheets to be copied, not just bored and closed?

The code is as follows:

  Sub Generated Letter () Application.ScreenUpdating = Resume Wrong OBack Error as Workbook Resume oBook = Workbooks (" SSReport.xls ") If the obbook is nothing, set the application to the album. Workbook Open ("SSReport.xls") If the error ends on Goto, I dim the string as an integer dim sheet in the form of J as worksheet construction attachment number = 63 dim plus (1 to 2 numbers, 1 to 2 ) For the number of numbers (i, 1) = oBook.Sheets ("SSPairings") .Red (i + 1) to add I = 1 as a string. (1, 1) gametes (i, 2) = oBook.Sheets ("spiers"). Rows (i + 1). (2) Next I added to i = 1 if I rebuild the mod 5 = 0 again. Close CloseChanges: = True Set Obooq = None set Ohok = App. Workbook Open ("SSReport.xls") if the application ends. Screen updating = False j = oBook.Worksheets.Count SheetName = "P" & amp; Participation (i, 1) & amp; (I, 2) The next set on the error restart ws = oBook.Sheets (SheetName) if ws do nothing then go to error ook.Sheets ("MasterFormat"). Cc: = Sheets (J) oBook.Sheets ("MasterFormat (2)"). Name = SheetName end if obec. Sheets (sheetName). (1, 2) = Parts (i, 1) obook. Sheets (sheetName) .Cell (1, 5) = Parts (i, 2) oBook. Sheets (sheet nim). Seals (1, 8) = "P" Next Eye Application Screen Updating = True and All  

This is a meta workbook that was suggested, link above the KB article. Interesting thing is that despite the open workbook , It does not really work if the main workbook is not open.

The error is probably due to this line:

  oBook. Sheets ("MasterFormat"). Copy: = Sheets (j)  <

Sheets (j) will remain in the code modules, which will refer to the workbook, which can not be a workbook.

The following works for me:

  Sub-generated sheet () As long as the slow ock dim me as a workbook long long dim sheet in the form of Jammu As the string dim, the worksheet formation pair as calculated in the form of calculation = 63 dim sum (1 to 2 numbers, 1 to 2) as the error resets the string on the next set oBook = workbooks ("SSReport.xls") error GoTo But 0 if obbook is nothing, then obok = un Set experiment. Workbook Join I (i, 1) = to end with the open ("SSReport.xls") IBook for I = 1. Sheet ("SPEERING"). Rows (i + 1). (1) Tapping (i, 2) =. Sheet ("SSPAIR Ings"). Rows (i + 1). (2) Next to i by adding i = 1 if I save mod 5 = 0 then '// in case of corruption / error?' . Save if J .Worksheets.Count SheetName = "P" & amp; Participation (i, 1) & amp; (I, 2) Start the error again Start over ws = .Sheets (SheetName) error 0 If zero is nothing. Sheet ("MasterFormat"). Cc: = Sheets (J). Sheet ("Masterformat 2)"). If name = SheetName end Sheets (sheetName). Cell (1, 2) = gamete (i, 1). Sheet (sheetname). (1, 5) = Fairs (i, 2). Sheet (sheetname). (1, 8) = "P" with the next end and toe end subset  

I have taken the liberty to close / reopen a simple save Should that get the same results?


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -