Running VBA script causes excel to stop responding

后端 未结 2 847
灰色年华
灰色年华 2021-01-12 11:34

I have a VBA script that adds sheets to around 500 excel files. I had no problems running the VBA script and adding simple sheets, but when I try to add a sheet with VBA scr

2条回答
  •  别那么骄傲
    2021-01-12 12:10

    I have finally solved my problem...

    The solution was to add a line of code:

    Application.Wait (Now + TimeValue("0:00:01"))
    

    after the line:

    sh.Copy After:=wb.Sheets(wb.Sheets.Count)
    

    which allowed time to copy the sheet to the new excel file.

    So far it has been working like a charm.

    I want to thank everyone that helped me with this issue.

    Many Thanks.

提交回复
热议问题