Copy all range names from one workbook to another

Farmland

New Member
Joined
Aug 15, 2022
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hi all,

I want to copy the names defined in one workbook "book1.xls" to tab "TD" in another workbook "Book2.xls".

The Source sheet used contains more than 1000 defined names. I tried a few codes I found online, but non of them worked.

I would really appreciate any advise you can give.

Thank you!
Sue
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi Sue, welcome to the MrExcel Forum.
How about this code placed in book1.xls. The code will place the results Book2 on Worksheets("TD") starting in Cell A1. If you don't want to start there, please change where indicated. Book2 must be open already.

VBA Code:
Sub findNames()

    Dim wb As Workbook: Set wb = ThisWorkbook
    Dim i As Long, arr
   
    ReDim arr(1 To wb.Names.Count, 1 To 2)
    For i = 1 To wb.Names.Count
       arr(i, 1) = wb.Names(i).Name
       arr(i, 2) = "'" & wb.Names(i).RefersTo
    Next
    Workbooks("Book2.xls").Worksheets("TD").Range("A1").Resize(UBound(arr), 2) = arr   'Change Range("A1") to your requirement

End Sub
 
Upvote 0
Thank you so much igold for your help. I really appreciate it.
 
Upvote 0
You're welcome, I was happy to help. Thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,215,449
Messages
6,124,911
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top