I have a workbook open which has a tab called "Previous". I want to open another workbook using VBA, copy the data from Sheet1 in that workbook, and paste it into the "Previous" tab in the current workbook.
I can get the macro to:
1.) Prompt for the workbook to open
2.) Open the Workbook
Using this code (Found by Googling)
Dim wbk As Workbook
Dim destWbk As Workbook
Set destWbk = ActiveWorkbook
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose the previous file to import", _
FileFilter:="Excel Files *.xls (*.xls),")
If FileToOpen = False Then
MsgBox "No file specified.", vbExclamation, "Duh!!!"
Set wbk = Workbooks.Open(FileToOpen)
' Need to copy the source and paste it
What I can't figure out is how to copy the data from the workbook I opened into my current workbook tab named "Previous". I've tried many examples, but I just keep getting Paste errors (like error 1004).
I need some help to:
1.) Prompt the user for a workbook to open
2.) Select and copy the contents of the first sheet of that workbook
3.) Paste the copied contents into the "Previous" tab of my current workbook.