Hi,
Everytime I run this code, it works on the first i but when it does the loop, on the next i, my excel crashes or I got an error 13.
first i = Louis101.xlsm, next i = Louis102.xlsm... etc. there are 20 "i"s.
I think it crashes when on the second loop, it reads the line: Application.Run nameofthedata & "!start"
but I'm not sure about that.
what I don't understand is if I try my macro a second time by switching i to 2, it will work the first time again but crashed on next i.
Do you know where is the problem?
Everytime I run this code, it works on the first i but when it does the loop, on the next i, my excel crashes or I got an error 13.
first i = Louis101.xlsm, next i = Louis102.xlsm... etc. there are 20 "i"s.
I think it crashes when on the second loop, it reads the line: Application.Run nameofthedata & "!start"
but I'm not sure about that.
what I don't understand is if I try my macro a second time by switching i to 2, it will work the first time again but crashed on next i.
Do you know where is the problem?
Code:
Sub weekend()
On Error Resume Next
Dim nameofthedata As String
Dim i As Integer
i = i
For i = 1 To 20
nameofthedata = Worksheets("DATAlist").Cells(i, 1).Value
Workbooks.Open Filename:= _
"C:\Users\Louis\Documents\backup\DATA\" & nameofthedata & ""
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\Louis\Documents\results\DATA\" & nameofthedata & "", FileFormat _
:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Application.Run nameofthedata & "!start"
Workbooks(nameofthedata).Close savechanges:=True
ThisWorkbook.Activate
nameofthedata = 0
Next i
End Sub