defined names

ehsas

Board Regular
Joined
Sep 17, 2002
Messages
200
How can i copy the defined names from one workbook and paste the same into another workbook.Regards
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
myNme = Range(nm).Address(False, False)

It was highliting the above statement.As you said i changed the mynme to mynme1 still it highliting the statement.I deleted the statement other statement is also highliting.You can try and see.Regards,
 
Upvote 0
I tested it with:

myNme1 = Range(nm).Address(False, False)

and I get no errors.

What is the error in Excel's dialog box when the code fails?
 
Upvote 0
i am getting following error message:-

runtime error 1004

method range of object global failed.
 
Upvote 0
It doen't like the Address property with dynamic ranges like yours.

This seems to work:

Code:
Sub Cpy_NmRngs()
    Dim nm As Name
    Dim myNme1 As String
    Dim myNme2 As String
    Dim NewBook As String
    NewBook = "Book2.xls" 'change Book2 to the name of target workbook
    For Each nm In ThisWorkbook.Names
        myNme1 = nm.Name
        myNme2 = nm.RefersTo
        Workbooks(NewBook).Names.Add Name:=myNme1, RefersTo:=myNme2
    Next nm
End Sub
 
Upvote 0
Workbooks(NewBook).Names.Add Name:=myNme1, RefersTo:=myNme2

it stops at above statement and giving me error message as follow:-

runtime error 9
subscript out of range.

Regards,
 
Upvote 0
yes i change but still it giving me same error messege.I have copied the macro to my source file. and run the macro.Let me tell you that I have more than one defined names in my workbook.I hope it not make any difference.Regards,
 
Upvote 0

Forum statistics

Threads
1,214,620
Messages
6,120,554
Members
448,970
Latest member
kennimack

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