Trying to open and copy from two EXCEL workbooks simultaneously

VAPALIPOT

New Member
Joined
Jan 18, 2010
Messages
14
I am trying to open two workbooks using VBA, then copy selected contents from one to second. I wrote this code and can get the first workbook to open, then nothing happens. I am wondering if I should just open the first workbook, copy the selected contents to the desktop, close the first file, open the second and then paste?? Its been a while since I did VBA coding and my skills are pretty rusty. Thanks for your help;
Sub EvalResults()
Dim fProfFileNameAndPath As Variant
Dim folderSource As Variant
Dim myFile As String
Dim myPath As String
Dim myExtension As String
Dim wbProf As Workbook
Dim wbDest As Workbook
Dim filepathProf As String
Dim filepathDest As String
Dim LastRow As Long
Dim FldrPicker As FileDialog

fProfFileNameAndPath = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),*.xls", Title:="Select Analyte Profile File To Be Opened")
If fProfFileNameAndPath = False Then Exit Sub
Set wbProf = Workbooks.Open(fProfFileNameAndPath)

'Retrieve Target Folder Path from User
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)

With FldrPicker
.Title = "Select the Gen5 Prorenin Results Folder"
.AllowMultiSelect = False
myPath = .SelectedItems(1) & ""
End With

'Targe File Extension (must include wildcard "*")
myExtension = "*.xls*"

'Target Path With Ending Extension
myFile = Dir(myPath & myExtension)

'filepathProf = Application.GetOpenFilename("Excel Files (*.xlsx), *.xlsx*, *.xls", , , False)
'Set wbProf = Workbooks.Open(filepathProf)

'filepathDest = Application.GetOpenFilename("EXCEL Files (*.xlsx), *.xlsx*, *.xls", , , False)
'Set wbDest = Workbooks.Open(filepathDest)

With wbProf
.Sheets("Sheet1").Range("A1:D15").Copy wbDest.Sheets("Sheet1").Range("M17:P31")
.Sheets("Sheet1").Range("B19:B93").Copy wbDest.Sheets("Sheet1").Range("I76:I150")
End With

wbProf.Close SaveChanges:=False

End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top