Solved

Excel VBA copy all named ranges to workbook

Posted on 2013-01-07
5
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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 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.

752 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