yuryyuryyury
New Member
- Joined
- Jul 3, 2007
- Messages
- 19
I am having trouble ending a macro when the user clicks cancel on the open file dialog box that opens when they run the macro. GetOpenFilename returns false when you click cancel, but I can't get any further than that.
Thank you!
Thank you!
Code:
Sub LoadLV()
Dim wb As Workbook
Dim pickfile As Variant
'Show the open dialog and pass the selected file name to "pickfile"
pickfile = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls), *.xls", _
Title:="Choose File", MultiSelect:=False)
'If they have cancelled
If pickfile = "False" Then End Sub
Set wb = Workbooks.Open(pickfile, True, False) ' open the source workbook with write permissions
wb.Worksheets(1).Range("C6").Copy
ThisWorkbook.Activate
ActiveCell.Offset(0, 19).Range("A1").Select
ActiveSheet.Paste Link:=True
end sub