![]() |
#5
|
|||
|
|||
![]()
A bit basic, but this should do what you want.
The file location needs to be in cell B1 and the file name in B2 Code:
Sub ImportFile() Dim fLocation As String Dim fName As String Dim CurrentfName As String CurrentfName = ActiveWorkbook.Name fLocation = ActiveSheet.Range("B1") fName = ActiveSheet.Range("b2") If Len(Dir(fLocation & fName, vbDirectory)) = 0 Then MsgBox Title:="Error", Prompt:="Cant find file" Exit Sub End If If Right(fLocation, 1) <> "/" Then fLocation = fLocation & "/" End If Workbooks.Open (fLocation & fName) ActiveSheet.Copy Workbooks(CurrentfName).Sheets(1) Workbooks(fName).Close False End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
tarunbaweja | Excel Programming | 1 | 03-20-2016 06:52 AM |
Hyperlink Format varies, depending on whether Target file was saved or unsaved on Hyperlink Copy | RichardDavey | Word | 0 | 05-26-2015 05:26 PM |
An error occurred while importing this file <image file> | melvinjn | Drawing and Graphics | 1 | 01-19-2015 01:32 AM |
![]() |
Sabi | PowerPoint | 1 | 04-30-2013 06:36 AM |
![]() |
Swoosh983 | Outlook | 1 | 08-20-2010 01:31 AM |