Solved

Excel VBA copy all named ranges to workbook

Posted on 2013-01-07
5
445 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 500 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

821 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