Solved

Excel VBA copy all named ranges to workbook

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now