ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import two worksheets into workbook (https://www.excelbanter.com/excel-programming/368124-import-two-worksheets-into-workbook.html)

dan

Import two worksheets into workbook
 
Hi,

I would like to run a macro which will work like this:

MsgBox "Select file 1"
- Import data dialog box to allow user to select an excel file
MsgBox "Select file 2"
- Import data dialog box to allow user to select an excel file

I dont want to define the path or filename, but want the user to be
able to select the file to import.

Thank you ahead of time for your help!!!!

Dan


Tom Hutchins

Import two worksheets into workbook
 
I always use code lke this to have the user select a file (without actually
opening the file yet).

Dim Fyle1 As String
'The user needs to select the file from which data should be retrieved.
'GetOpenFilename displays a standard File Open dialog, but it only gets
'the file name - it doesn't open the file.
Fyle1$ = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
'If no file was selected (Cancel clicked), stop the macro.
If Fyle1$ = "False" Then Exit Sub

'Open the selected workbook.
Workbooks.Open Filename:=Fyle1$

Hope this helps,

Hutch

"dan" wrote:

Hi,

I would like to run a macro which will work like this:

MsgBox "Select file 1"
- Import data dialog box to allow user to select an excel file
MsgBox "Select file 2"
- Import data dialog box to allow user to select an excel file

I dont want to define the path or filename, but want the user to be
able to select the file to import.

Thank you ahead of time for your help!!!!

Dan




All times are GMT +1. The time now is 05:18 PM.

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