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
So, some tips for you:
1st. (according to comment)
Add as a first line to your sub: Application.ScreenUpdating = false
and add the other line right before End Sub
: Application.ScreenUpdating = true
2nd. Move this line (it's setting constance reference):
Set wb = Workbooks("Equipment Further Documentation List.xls")
before:
Do Until txtStream.AtEndOfStream
3rd is just a tip.
To see the progress of your sub add the following line:
Application.StatusBar = file.Name
after this line:
Workbooks.Open strNextLine & Application.PathSeparator & file.Name
Before the End Sub
add additionally this code:
Application.StatusBar = false
As a result you can see in Excel app, in the status bar, file name which is currently in process.
Keep in mind that working with 500 files must be time-consuming.
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.