Sub Test()
Dim oneName As Name
For Each oneName In ThisWorkbook.Names
If TypeName(Evaluate(oneName.RefersTo)) = "Range" Then
If Not (oneName.Name Like "P_*") Then
oneName.RefersToRange.Name = "P_" & oneName.Name
oneName.Delete
Call Test
Exit Sub
End If
End If
Next oneName
End Sub
You could use this sub
Code:oneName.RefersToRange.Name = "P_" & oneName.Name
Hey try this out
Code:Sub AddPre() Dim dataCol As Range Dim r As Range Set dataCol = Range("A1:A15") For Each r In dataCol r.Value = "P_" & r.Value Next r End Sub
just change the range to where ever your data is
Hmm.. it works for me. What is the value of oneName.Name and OneName.RefersToRange.Address when the error occurs?Thanks a lot for your help.
I'm getting the error "Wrong number of arguments or invalid property assignment" error message when I execute the code, it's showing the error on the above line.
Hi MikeHmm.. it works for me. What is the value of oneName.Name and OneName.RefersToRange.Address when the error occurs?
Oh, I see, sorry. So one named range is "BroIsOnHoliday" and the formula in the RefersTo box is:What would the RefersTo of a named range be, typically.
=OFFSET(BroList!$AK$1,1,0,COUNTA(BroList!$A:$A)-1,1)
(RefersTo:) =Home!$A$1:$A$2
Sub Test()
Dim oneName As Name
For Each oneName In ThisWorkbook.Names
If Not (oneName.Name Like "P_*") Then
ThisWorkbook.Names.Add Name:= "P_" & oneName.Name, RefersTo:=oneName.RefersTo
oneName.Delete
End If
Next oneName
End Sub