Consulting

Results 1 to 4 of 4

Thread: Copy and rename named cells in a sheet to another sheet

  1. #1
    VBAX Newbie
    Joined
    Sep 2011
    Posts
    2
    Location

    Copy and rename named cells in a sheet to another sheet

    Is there some simple VBA code that will allow me to:

    copy the 'names' in the name manager referring to cells in worksheet one and offset those names with a text prefix (i.e. tab2'cellname') and apply these new names to identical ranges in worksheet two?

    Any help appreciated.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim nme As Name

    Set nme = ActiveWorkbook.Names("cellName")
    ActiveWorkbook.Names.Add Name:="tab2" & nme.Name, _
    RefersTo:="=Sheet2!" & Right$(nme.RefersTo, Len(nme.RefersTo) - InStr(nme.RefersTo, "!"))
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Sep 2011
    Posts
    2
    Location

    Thanks

    as a very novice user of VBA (almost none) - how would I apply this code in the workbook I wish to copy named cells inside of?

    What parts of the code do I input values to so it works?

    Thanks :-)

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Just create a simple macro, changes the strings to your values and run it.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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