open file dialog-select file-import worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone help me? I am able to do this in access but seem to can't get it to work in excel

What I would like to do is open a file dialog and select a file (generic/any file) and when that file is selected, the worksheet within the file selected is imported or copied into a file that is already opened

In other words, I have an automated form that I have created and the worksheet within the file that is selected, that worksheet is imported or copied into the file next to the automated form

Thank you in advance for your help.
 
Dim fName as String
Dim wkbk as Workbook
fName = Application.GetOpenFileName()
if fName <> "False" then
set wkbk = Workbooks.Open(fName)
wkbk.Worksheets(1).Copy After:=ThisWorkbook.Worksheets( _
ThisWorkbook.Worksheets.count)
wkbk.close SaveChanges:=False
End if

--
Regards,
Tom Ogilvy


Divinedar said:
Can someone help me? I am able to do this in access but seem to can't get it to work in excel.

What I would like to do is open a file dialog and select a file
(generic/any file) and when that file is selected, the worksheet within the
file selected is imported or copied into a file that is already opened.
In other words, I have an automated form that I have created and the
worksheet within the file that is selected, that worksheet is imported or
copied into the file next to the automated form.
 
Back
Top