VBA to Copy and Paste From One Workbook to Another

rbellavance22

New Member
Joined
Aug 8, 2019
Messages
14
Hello,

I have two workbooks, 2018 and 2019. Both have 100+ tabs with different names.

2018 has data in various cells throughout each tab.

2019 has the same number of tabs with the same titles as 2018, but is completely blank otherwise.

I would like to copy multiple cells from 2018 (A4, B18, C86, C88 & D1) and paste them into a different cell (A4 in 2018 gets pasted into A12 in 2019, etc.) in the corresponding tab in the 2019 workbook.

Any and all help would be much appreciated.

Thank you.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You mentioned where A4 in 2018 gets pasted. What about B18, C86, C88 and D1?
 
Upvote 0
Make sure that both workbooks are open. Place this macro in the "2018" workbook. Change the workbook name in the code (in red) to suit your needs.
Code:
Sub CopyCells()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, desWB As Workbook
    Set desWB = Workbooks("[COLOR="#FF0000"]2019.xlsx[/COLOR]")
    For Each ws In Sheets
        With desWB
            With .Sheets(ws.Name)
                .Range("A12") = ws.Range("A4")
                .Range("B89") = ws.Range("B18")
                .Range("C88") = ws.Range("C8")
                .Range("J18") = ws.Range("D1")
            End With
        End With
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
This is incredible. You saved me hours, and hours, and hours of data entry. Thank you so much!!

Make sure that both workbooks are open. Place this macro in the "2018" workbook. Change the workbook name in the code (in red) to suit your needs.
Code:
Sub CopyCells()
    Application.ScreenUpdating = False
    Dim ws As Worksheet, desWB As Workbook
    Set desWB = Workbooks("[COLOR=#FF0000]2019.xlsx[/COLOR]")
    For Each ws In Sheets
        With desWB
            With .Sheets(ws.Name)
                .Range("A12") = ws.Range("A4")
                .Range("B89") = ws.Range("B18")
                .Range("C88") = ws.Range("C8")
                .Range("J18") = ws.Range("D1")
            End With
        End With
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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