Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.
Private Sub Import_Data_Into_Current_Workbook_EE() Dim customerFilename As String Dim customerWorkbook As Workbook Dim targetWorkbook As Workbook ' active workbook is the target Set targetWorkbook = Application.ActiveWorkbook With Application.fileDialog(msoFileDialogOpen) .ButtonName = "&Open" .InitialFileName = "C:\MyFile\Data" .Filters.Clear .Filters.Add "Excel files (*.xls; *.xlsm; *.xlsx)", "*.xls;*.xlsm;*.xlsx", 1 .Title = "Please Select an input file" .AllowMultiSelect = False End With If Not (Application.fileDialog(msoFileDialogOpen).Show) Then MsgBox "No File specified!.", vbExclamation, "Cancel has been pressed!" Exit Sub Else customerFilename = Application.fileDialog(msoFileDialogOpen).SelectedItems(1) Set customerWorkbook = Application.Workbooks.Open(customerFilename) Dim sourceSheet As Worksheet Set sourceSheet = customerWorkbook.Worksheets(1) On Error Resume Next Set srcSht = targetWorkbook.Sheets(sourceSheet.Name) On Error GoTo 0 If IsEmpty(srcSht) Then sourceSheet.Copy Before:=targetWorkbook.Sheets(1) Else MsgBox "Sheet name already there" Exit Sub End If End If customerWorkbook.Close End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.