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
    14

    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
    14
    Thanks for the help, much appreciated

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    http://www.eileenslounge.com/viewtopic.php?f=30&t=41784
    http://www.eileenslounge.com/viewtopic.php?p=323966#p323966
    http://www.eileenslounge.com/viewtopic.php?p=323959#p323959
    http://www.eileenslounge.com/viewtopic.php?p=323960#p323960
    http://www.eileenslounge.com/viewtopic.php?p=323894#p323894
    http://www.eileenslounge.com/viewtopic.php?p=323843#p323843
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa6BSa173Z
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa6-64Xpgl
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa5ms39yjd
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa5ZXJwRCM
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa4Pr15NUt
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABa4I83JelY
    https://www.youtube.com/watch?v=C43btudYyzA&lc=Ugyf349Ue6_4umFfNUB4AaABAg. 8mjgPNoTt_HABa3tnAjhZU
    https://www.youtube.com/watch?v=C43btudYyzA&lc=Ugyf349Ue6_4umFfNUB4AaABAg. 8mjgPNoTt_HABa3KswxL3c
    https://www.youtube.com/watch?v=suUqEo3QWus&lc=UgyBXFxnVWT3pqtdqPx4AaABAg
    https://www.youtube.com/watch?v=suUqEo3QWus&lc=Ugi53h84LUm5bHgCoAEC.7-H0Z7-COoGABZFQ8vjEvY
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABZ8N9O-O8p
    http://www.eileenslounge.com/viewtopic.php?p=323547#p323547
    http://www.eileenslounge.com/viewtopic.php?p=323516#p323516
    http://www.eileenslounge.com/viewtopic.php?p=323517#p323517
    http://www.eileenslounge.com/viewtopic.php?p=323449#p323449
    http://www.eileenslounge.com/viewtopic.php?p=323226#p323226
    http://www.eileenslounge.com/viewtopic.php?f=25&t=41702&p=323150#p323150
    http://www.eileenslounge.com/viewtopic.php?p=323085#p323085
    http://www.eileenslounge.com/viewtopic.php?p=322955#p322955
    http://www.eileenslounge.com/viewtopic.php?f=30&t=41659
    https://www.youtube.com/watch?v=suUqEo3QWus&lc=Ugi53h84LUm5bHgCoAEC.7-H0Z7-COoGABZFQ8vjEvY
    https://www.youtube.com/watch?v=3t8Mk4URi6g&lc=UgzoakhRXOsCaoRm_Nd4AaABAg. 8xzeMdC8IOGABZ8N9O-O8p
    https://www.youtube.com/watch?v=C43btudYyzA&lc=UgxREWxgx2z2Lza_0st4AaABAg
    https://www.youtube.com/watch?v=C43btudYyzA&lc=UgyikSWvlxbWS24NBeR4AaABAg
    https://www.youtube.com/watch?v=C43btudYyzA&lc=UgwNiH4hhyrd2UjDK8d4AaABAg
    https://www.youtube.com/watch?v=C43btudYyzA&lc=Ugyf349Ue6_4umFfNUB4AaABAg. 8mjgPNoTt_HAAf952WoUti
    https://www.youtube.com/watch?v=hz4vb48wzMM&lc=Ugy2N3gvXBNrvWpojqR4AaABAg
    http://www.eileenslounge.com/viewtopic.php?p=322462#p322462
    http://www.eileenslounge.com/viewtopic.php?p=322356#p322356
    http://www.eileenslounge.com/viewtopic.php?p=321984#p321984
    https://eileenslounge.com/viewtopic.php?f=30&t=41610
    https://eileenslounge.com/viewtopic.php?p=322176#p322176
    https://eileenslounge.com/viewtopic.php?p=322238#p322238
    https://eileenslounge.com/viewtopic.php?p=322270#p322270
    https://eileenslounge.com/viewtopic.php?p=322300#p322300
    http://www.eileenslounge.com/viewtopic.php?p=322150#p322150
    http://www.eileenslounge.com/viewtopic.php?p=322111#p322111
    http://www.eileenslounge.com/viewtopic.php?p=322086#p322086
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 01-09-2025 at 01:03 AM.

  4. #4
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    14
    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
  •