Link to home
Start Free TrialLog in
Avatar of mike637
mike637Flag for United States of America

asked on

Excel VBA copy all named ranges to workbook

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
Avatar of redmondb
redmondb
Flag of Afghanistan image

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
Avatar of mike637

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of redmondb
redmondb
Flag of Afghanistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mike637

ASKER

Thanks once again Brian!

I really appreciate you.

Michael
Glad to help, Michael!