Copy & paste multiple 'Named Ranges' from different worksheets to a new workbook using VBA

kyip825excel

New Member
Joined
Mar 31, 2014
Messages
17
Hi,

I need help with building a vba script that would copy & paste-append all of my data from their defined "Named ranges" from one workbook to a new workbook. The workbook where I'm copying from has multiple worksheets and they each have their own set of data with their own named ranges defined.

Can someone please help?

Thanks,

Ken

Partial script below (notice that it is repeated with difference worksheets and named ranges but I have over 50 of them so I need to be able to loop them or use Do Until all worksheets are copied):

Windows("JFajarta Mar Submission - Publishing.xlsx").Activate
Sheets("PiB").Select
Range("PiBrange").Copy
Windows("March Consolidation - JFajarta.xlsm").Activate
Sheets("Consolidate").Select
Range("A2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("JFajarta Mar Submission - Publishing.xlsx").Activate
Sheets("PiB").Select
Range("PiBrangeNew").Copy

Windows("March Consolidation - JFajarta.xlsm").Activate
Sheets("Consolidate").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("JFajarta Mar Submission - Publishing.xlsx").Activate
Sheets("Mad3").Select
Range("Mad3range").Copy
Windows("March Consolidation - JFajarta.xlsm").Activate
Sheets("Consolidate").Select
Range("A2").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

Windows("JFajarta Mar Submission - Publishing.xlsx").Activate
Sheets("Mad3").Select
Range("Mad3rangeNew").Copy

Windows("March Consolidation - JFajarta.xlsm").Activate
Sheets("Consolidate").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
 

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,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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