After finding solution to the file name problem, I'm now encountering a problem with crashes.. After using this macro for several times (5-6) Excel 2010 crashes.
Do you have any idea what might be causing this or what to change in the code to prevent those crashes?
The code:
Sub Import3()
Dim File As Variant
Dim Master As Variant
MsgBox "Choose file", vbOKOnly
File = Application.GetOpenFilename("Excel files (*.xls),*.xls", , "Open an Excel file...")
File = Mid(File, InStrRev(File, "\") + 1)
If Not File = False Then Workbooks.Open (File)
Master = ThisWorkbook.Name
Sheets(1).Activate
Range("G13").Select
Selection.Copy
Windows(Master).Activate
Range("G13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(File).Activate
Range("G18").Select
Selection.Copy
Windows(Master).Activate
Range("G18").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows(File).Activate
ActiveWorkbook.Close True
MsgBox "Import completed"
End Sub
Bookmarks