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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,215,471
Messages
6,125,000
Members
449,202
Latest member
Pertotal

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