Copt pasting data from one workbook to another

Shree1

New Member
Joined
Sep 8, 2014
Messages
31
Hi,

I'm new to VBA so apologies for asking simple questions!

I have a workbook called "ME". I want to write a macro that will import data from columns A1 till J5000 in worksheet"temp" in another workbook called "XY", and put them in a worksheet called "IM" in the original workbook. Can someone please help me with the code. I also want to put in a code that will opne up workbook "XY" in case it is not open.
Thanks!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi,

I'm new to VBA so apologies for asking simple questions!

I have a workbook called "ME". I want to write a macro that will import data from columns A1 till J5000 in worksheet"temp" in another workbook called "XY", and put them in a worksheet called "IM" in the original workbook. Can someone please help me with the code. I also want to put in a code that will opne up workbook "XY" in case it is not open.
Thanks!
You will find all the info you need here
 
Upvote 0
Thanks. How do I specify the location path of the source file?

Code:
Sub Copycat()'    Dim vFile As Variant
'    Dim wbCopyTo As Workbook
'    Dim wsCopyTo As Worksheet
'    Dim wbCopyFrom As Workbook
'    Dim wsCopyFrom As Worksheet
'
'
'    Set wbCopyTo = ActiveWorkbook
'    Set wsCopyTo = ActiveSheet
'
'        '-------------------------------------------------------------
'        'Open file with data to be copied
'
'        vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
'        "*.xl*", 1, "Select Excel File", "Open", False)
'
'        'If Cancel then Exit
'        If TypeName(vFile) = "Boolean" Then
'            Exit Sub
'        Else
'        Set wbCopyFrom = Workbooks.Open(vFile)
'        Set wsCopyFrom = wbCopyFrom.Worksheets(1)
'        End If
'
'        '--------------------------------------------------------------
'        'Copy Range 3000 soft limit
'        wsCopyFrom.Range("a1:af3000").Copy
'
'        wsCopyTo.Range("a1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, _
'                Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'
'
'
'
'
'        wbCopyFrom.Save
'
'
'
'        'Close file that was opened
'        wbCopyFrom.Close SaveChanges:=False
'


'
'End Sub
 
Upvote 0
vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _ "*.xl*", 1, "Select Excel File", "Open", False)

did not work.

So, my workbook name is "XY" an dthe filepath is c:...\xy.xls
 
Upvote 0
The workbook I am opening is "XY" in location c:\mamama\XY.xls. The worksheet that has the data to be copied is called "temp" and the range is A1 to J5000. I want to copy it to a worksheet called "IM" in my active workbook. Can you please tell me how to do that with the above code
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,476
Members
448,967
Latest member
visheshkotha

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