I have a very simple macro.
User can choose a file (click a button for example if I add this macro to a button) then if clicks ok then the file name will be added to field E6 (I will need it later for other macros) and the file will be opened.
My problem is if the user choose Cancel then the file which name is in E6 already will be opened. How can I avoid this?
Sub VChoose_folder()
v = "nothing"
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Choose file"
.AllowMultiSelect = False
.InitialFileName = CurDir
If .Show = -1 Then v = .SelectedItems(1)
End With
If v <> "nothing" Then
Range("E6").Value = v
End If
Workbooks.Open Filename:=Range("E6")
End Sub
Bookmarks