danielbond
New Member
- Joined
- Nov 24, 2017
- Messages
- 3
Dear all,
I am going to change a bundle of excels which named according to incomplete ascending number( etc: first one calls 1_2016, second calls 2_2016, but the third calls 4_2016, etc.), my purpose is renew their names in 2017 instead of 2016.
However, I encounter into using loop, when I set i =1 to 4, VBA would show error message when it finished running i=2, how can I adjust the command to let the loop can skip n(3) automatically while it does not have any corresponding file?
The following is my current steps:
Dim n(4) As String
n(1) = "1"
n(2) = "2"
n(4) = "4"
For i = 1 To 4
(...skip the path setting...)
ActiveWorkbook.SaveAs (n(i)&"_2017")
ActiveWorkbook.Close
Next i
End Sub
Thank you guys!!
I am going to change a bundle of excels which named according to incomplete ascending number( etc: first one calls 1_2016, second calls 2_2016, but the third calls 4_2016, etc.), my purpose is renew their names in 2017 instead of 2016.
However, I encounter into using loop, when I set i =1 to 4, VBA would show error message when it finished running i=2, how can I adjust the command to let the loop can skip n(3) automatically while it does not have any corresponding file?
The following is my current steps:
Dim n(4) As String
n(1) = "1"
n(2) = "2"
n(4) = "4"
For i = 1 To 4
(...skip the path setting...)
ActiveWorkbook.SaveAs (n(i)&"_2017")
ActiveWorkbook.Close
Next i
End Sub
Thank you guys!!