coping 4 columns from 2 separate workbooks into 1 central workbook

lyndseygus

New Member
Joined
Aug 8, 2017
Messages
3
Hello,

I have never done excel macro's . I am looking for one that will copy columns a and b from "workbook.xlsx" and columns c and d from "workbook2.xlxs" to "Master workbook.xlsm".

Any help would be greatly appreciated.
:)
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hello,

Try this out...Just change the red text to your specifications im sure you can tell what kind of information is needed in its place

To open the editor do ALT + F11 then go to insert and select module

Here you will paste the code below and like i said just change the red text to your specifications and click run and it should work.

Make sure both workbook.xlsx and workbook2.xlsx are closed before you run it

Code:
Sub XferData()
    Dim Current As Workbook
    Dim Book1 As Workbook
    Dim Book2 As Workbook
    
    Set Current = ActiveWorkbook
    Set Book1 = Workbooks.Open("[B][COLOR=#ff0000]Insert path of workbook.xlsx[/COLOR][/B]")
    Set Book2 = Workbooks.Open("[B][COLOR=#ff0000]Insert path of workbook2.xlsx[/COLOR][/B]")
[B][COLOR=#ff8c00]'Example of the workbook paths would be something like "C:\Users\Desktop\New folder\workbook.xlsx"[/COLOR][/B]


    Current.Sheets("[B][COLOR=#ff0000]Sheet1[/COLOR][/B]").Range("A:B").Value = Book1.Sheets("[B][COLOR=#ff0000]Sheet1[/COLOR][/B]").Range("A:B").Value
    Current.Sheets("[B][COLOR=#ff0000]Sheet1[/COLOR][/B]").Range("C:D").Value = Book2.Sheets("[B][COLOR=#ff0000]Sheet1[/COLOR][/B]").Range("C:D").Value


    Book1.Close False
    Book2.Close False
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,730
Messages
6,132,388
Members
449,725
Latest member
Enero1

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