ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   open file dialog-select file-import worksheet (https://www.excelbanter.com/excel-programming/288215-open-file-dialog-select-file-import-worksheet.html)

Divinedar

open file dialog-select file-import worksheet
 
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.

Tom Ogilvy

open file dialog-select file-import worksheet
 
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" wrote in message
...
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.





All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com