locked
Failure For Next loop and Copy After RRS feed

  • Question

  • in a

    For XThis=1 to Application.Sheets.Count

    I am changing between to Workbooks and changing the sheet name

    The code works and has worked for a year or longer

    I made some changed to the "0Gamx" background code so I wanted to change all of them to match

    I have over 1000 sheets. When the code gets to about 518 cycles the screen gets garbaged up (after save and re-start Excel the sheets 519 and above are missing the Combo Box and 2 buttons)

    and the biggest issue in that on the "0Gamx" sheet their are 2 buttons and 1 combo box which now do not copy, the rest of the sheet and the page code copy just fine (see below)

                Workbooks(OldWb).Worksheets("0Gamx").Activate
                ActiveSheet.Copy After:=Worksheets(Sheets.Count)
                ActiveSheet.name = CurShtName

    I have tried this with Excel 2010, 2016 and 2019 all with the same results

    about 518 sheets will copy without a problem and after that the above problem happens

    Please let me know if you have an answer for this issue


    • Edited by markwpmi Thursday, December 17, 2020 12:48 PM
    Thursday, December 17, 2020 6:18 AM