"Subscript out of range" appeared when a non existant file was entered,
and the execution was aborted.
Can you help me to continue the execution?
Sub Analyse()
Dim Ans As Variant
Dim filename As String
Sheets("Sheet1").Select
Ans = InputBox(prompt:="Enter the data file name. ")
If Ans = "" Then Exit Sub
filename = Ans & ".csv"
On Error GoTo skip
Workbooks.Open filename:="F:\Cabinet1\" & filename, UpdateLinks:=0
' Main analysis body here
Exit Sub
skip:
Windows("ABC").Activate
Sheets("Sheet1").Range("H1") = Ans & " file does not exist!"
End Sub
Bookmarks