I need to exit the macro when if the user is not selecting any file and clicks "Cancel" in the file picker dialog box. Below is my exisintg code
Sub OpenFile()
With Application.FileDialog(msoFileDialogFilePicker)
.InitialFileName = ThisWorkbook.Path
If .Show <> -1 Then Exit Sub
strFile = .SelectedItems(1)
Sheets("Sheet1").Cells.ClearContents
Open strFile For Input As #1
i = 1
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, Text
Sheets("Sheet1").Range("A" & i) = Text
i = i + 1
Loop
Close #1
End With
End Sub
Sub Opertion()
OpenFile
End Sub()
Bookmarks