Macro/VBA to open, copy and paste data from other worksheets

CSC_BATS

New Member
Joined
Jun 10, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,
First post to this forum so please go easy on me..... ?

I have a workbook that has 20 seperate sheets which I need to copy 2 cells from another workbook with 20 sheets (all named the same), how or what is the easiest way to have a macro run to open the alternate worksheet and then copy cell range "contacts" sheet C5:D14 then paste it to "register" sheet C5:D15

See images that are attached for a basic overview of the required cells and contents.

CopyExample is the raw data that is needed to be populated to the PasteExample sheet.

Thanks in advance.

Apologies if it's a numpty question and solution....
 

Attachments

  • CopyExample.JPG
    CopyExample.JPG
    40.6 KB · Views: 6
  • PasteExample.JPG
    PasteExample.JPG
    38.2 KB · Views: 5

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi CSC_BATS and welcome to the forum. As nobody has responded I hope the following will help you get started. I believe the code below does something like what you need - copying from Test1.xlsx to Test2.xlsx. At least it may offer some starting point. Good luck!

VBA Code:
Sub CopyPaste_Test()
'Note: Assuming both Test1.xlsx and Test2.xlsx are open workbooks
    Windows("Test1.xlsx").Activate
    Sheets("contacts").Select
    Range("C5:D14").Select
    Selection.Copy
    Windows("Test2.xlsx").Activate
    Sheets("register").Select
    Range("C5").Select
    ActiveSheet.Paste
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,235
Messages
6,123,782
Members
449,123
Latest member
StorageQueen24

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