×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Copying sheets that have many named ranges

Copying sheets that have many named ranges

Copying sheets that have many named ranges

(OP)
thread770-361102: Copying sheets that have many named ranges

Copying sheet names from one sheet to another

CODE

Sub named_region()
    MY_SOURCE = InputBox("Enter Source Sheet Name")
    MY_DEST = InputBox("Enter Destination Sheet Name")
    
    Sheets(MY_SOURCE).Range("AA1").Select
        With Selection.ListNames
            For MY_ROWS = 1 To ActiveSheet.UsedRange.Rows.Count
                MY_RANGE_NAME = Range("AA" & MY_ROWS).Value & "1"
                MY_ADDRESS = Mid(Range("AB" & MY_ROWS).Value, 2, Len(MY_SOURCE))
                MY_RANGE = Mid(Range("AB" & MY_ROWS).Value, Len(MY_SOURCE) + 3, Len(Range("AB" & MY_ROWS).Value))
                a = Left(MY_ADDRESS, Len(MY_SOURCE) + 3)
                If Left(MY_ADDRESS, Len(MY_SOURCE) + 3) = MY_SOURCE Then
                    ActiveWorkbook.Names.Add Name:=MY_RANGE_NAME, RefersTo:="=" & MY_DEST & "!" & MY_RANGE
                End If
            Next MY_ROWS
        End With
    Sheets(MY_SOURCE).Columns("AA:AB").ClearContents
End Sub 

This has no error checking in the macro, so assumes you will type the sheet (tab) names in correctly.

----------------------------------
Hope this helps.
----------------------------------

been away for quite a while
but am now back

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close