Results 1 to 5 of 5

Thread: Excel VBA Macro To Move Named Range From One Workbook To Another

  1. #1
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    13

    Excel VBA Macro To Move Named Range From One Workbook To Another

    I have a workbook Group profits.2012. this workbook contains a large number of range names. I would like a macro to export/copy these range names into a new workbook Group profitts.2013


    Your assistance in this regard is most appreciated

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Code:
    Sub NameMover()
    
        Dim nm As Name
        
        For Each nm In Workbooks("NameOfTheBookWhereNamedRangesAreToBeMovedFrom").Names
            Workbooks("NameOfTheBookWhereNamedRangesAreToBeMovedTo").Names.Add nm.Name, nm.RefersTo, nm.Visible
        Next nm
        
    End Sub
    No error handling done.... so if the name already exists in the destination workbook, will throw an error.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    13
    Thanks for the help, much appreciated

  4. #4
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    13
    Hi Excel Fox

    You kindly assisted me by setting up code a while back to copy range names from onme workbook to another. It would be appreciated if you could amend your code to copy only those range names starting with HC for eg HC_Advertising , HC_PROV_BD etc

    Regards

    Howard

    I have also posted on Hi Excel Fox

    You kindly assisted me by setting up code a while back to copy range names from onme workbook to another. It would be appreciated if you could amend your code to copy only those range names starting with HC for eg HC_Advertising , HC_PROV_BD etc

    Regards

    Howard

    I have also posted on the following site http://www.mrexcel.com/forum/excel-q...nge-names.html
    Last edited by Howardc; 07-02-2013 at 11:20 AM.

  5. #5
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Code:
    Sub NameMover()
    
        Dim nm As Name
        
        For Each nm In Workbooks("NameOfTheBookWhereNamedRangesAreToBeMovedFrom").Names
            If Ucase(LEFT(nm.Name,2)) = "HC" Then
                Workbooks("NameOfTheBookWhereNamedRangesAreToBeMovedTo").Names.Add nm.Name, nm.RefersTo, nm.Visible
            End If
        Next nm
        
    End Sub
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Split Workbook In To Sheets, Export To Folder and Move File
    By doug@powerstroke.us in forum Excel Help
    Replies: 2
    Last Post: 05-22-2013, 06:45 PM
  2. Replies: 6
    Last Post: 05-20-2013, 10:06 PM
  3. Replies: 7
    Last Post: 05-17-2013, 10:38 PM
  4. Replies: 1
    Last Post: 02-14-2013, 12:09 PM
  5. Excel Macro to Sort Data if a value changes in defined range
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 4
    Last Post: 09-05-2012, 10:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •