I've looked all over the net trying to find coding to help my need. I've found some through this web site, but unable to get it to work correctly. What I'm trying to create is if a customer clicks on the button to copy the sheet (which has 28+ different name ranges) that when the sheet is copied it find and replace the named ranges with the new sheet name.
I appreciate all your help.
Thanks
Code:
Dim strTool As String
'
strTool = ActiveSheet.Name
ActiveSheet.Unprotect
Range("A1").Select
ActiveSheet.Select
oldTool = ActiveSheet.Name
ActiveSheet.Copy After:=ActiveSheet
ActiveSheet.Select
newTool = InputBox("What is the new sheet name?")
ActiveSheet.Unprotect
ActiveSheet.Name = newTool
Dim sSheet, lRow, n, Toolname, rngTool
sSheet = ActiveSheet.Name
lRow = 1
For Each n In ActiveSheet.Names
If Split(Right(n.RefersTo, Len(n.RefersTo) - 1), "!")(0) Like "*" & sSheet & "*" Then
Toolname = Split(Right(n.Name, Len(n.Name) - 10), "!" & oldTool)
Application.Goto Reference:=oldTool & Toolname(1)
rngTool = Selection.Address
ActiveWorkbook.Names.Add Name:=newTool & Toolname(1), RefersTo:= _
"=" & newTool & "!" & rngTool
lRow = lRow + 1
End If
Next
Cells.Replace What:=oldTool, Replacement:=newTool, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Thanks