Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel VBA copy all named ranges to workbook

Posted on 2013-01-07
5
Medium Priority
?
478 Views
Last Modified: 2013-01-07
Hello Experts,

I need to copy one workbook to another.  They are set up identically, however on one specific sheet, I need to copy the data in the named ranges to the identical named ranges in the 2nd workbook sheet. (I have other data on the sheet -  but do not want to copy that).

Is this possible?

Both sheets named "STAGING AREA" or Sheet12.
There are 35 identically named ranges in each sheet.
wb1 and wb2 have been declared.

Any assistance would be appreciated.

Thank you,
Michael
0
Comment
Question by:mike637
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:redmondb
ID: 38753033
Hi, Michael.

If I've understood you correctly, this is straightforward. I've included two files each with a name "Fred". the macro in One.xlsm copies its Fred to Two.xlsm. The line of code is...
wbk1 .Sheets("Sheet1").[Fred].Copy Destination:=wbk2.Sheets("Sheet1").[Fred]

Regards,
Brian.One.xlsmTwo.xlsx
0
 

Author Comment

by:mike637
ID: 38753051
I am sorry Brian, I guess I was off on how I worded by request,

I have 35 named ranges on wb1.sheet12 and I want to copy those to wb2.sheet12.

How can I have it find all named.ranges and copy those from wb1 to wb2 without having to list out each named range to copy.

Could it not be something like
            For each named.range in sheet12
            something something
or loop through the sheet and find each named range and copy it to wb2?

Michael
0
 
LVL 26

Accepted Solution

by:
redmondb earned 2000 total points
ID: 38753053
Michael,

Please see revised One.xlsm...
(1) It correctly refers to Two.xlsx (not Two.xlsm).
(2) You don't need to specify the names - it automatically processes all of them.

Edit: A crossing post, but I think I finally understood your requirements!

Regards,
Brian.One.xlsm
0
 

Author Closing Comment

by:mike637
ID: 38753064
Thanks once again Brian!

I really appreciate you.

Michael
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38753070
Glad to help, Michael!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question