Hello, I am trying to copy a whole worksheet from another workbook that the user can select and have it paste into a sheet in my workbook that my code is in. However with this code I am using it keeps opening a new workbook and pasting it there with the name of the sheet instead it is copied and also pasting my code in the sheet where i want to have the sheet i wanted copied from into there and thats not what i want.
Here is my code:
Sub GetData()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Select Workbook", FileFilter:="Excel Files (*.xlsm*), *xlsm*")
'& "Excel Files(*xlsm*), *xlsm*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets("Details").Copy
ThisWorkbook.Worksheets("Copy of Detail").PasteSpecial xlPasteValues
OpenBook.Close False
Else
MsgBox "No file was selected!"
End If
Application.ScreenUpdating = True
End Sub
trying to get it to copy from details sheet from the selected workbook the user picks and then paste into the workbook my code is in into a tab called, copy of detail. Not have it open a whole new workbook and paste it into a sheet in there calling it still details.
Thank you for any help!
Here is my code:
Sub GetData()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Select Workbook", FileFilter:="Excel Files (*.xlsm*), *xlsm*")
'& "Excel Files(*xlsm*), *xlsm*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets("Details").Copy
ThisWorkbook.Worksheets("Copy of Detail").PasteSpecial xlPasteValues
OpenBook.Close False
Else
MsgBox "No file was selected!"
End If
Application.ScreenUpdating = True
End Sub
trying to get it to copy from details sheet from the selected workbook the user picks and then paste into the workbook my code is in into a tab called, copy of detail. Not have it open a whole new workbook and paste it into a sheet in there calling it still details.
Thank you for any help!