R/T error 1004

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
Can anyone spot my problem? R/T occuring a/on Red Line...

Rich (BB code):
Sub Foo1()
For i = 1 To ActiveWorkbook.Names.Count
  CAddress = Mid(ActiveWorkbook.Names(i), WorksheetFunction.Find("!", ActiveWorkbook.Names(i)) + 1, 12)
  FullNameData = Names(i).Name
  FullNameData = WorksheetFunction.Substitute(FullNameData, "Block1", "Block2", 1)
  FullNameData = WorksheetFunction.Substitute(FullNameData, "b1day", "b2day", 1)
  PartNameData = Left(FullNameData, WorksheetFunction.Find("!", FullNameData) - 1)
  Worksheets(2).Names.Add Name:=PartNameData & "!" & CAddress 
 '.......
Next
End Sub

Thanks in Advance...

Jim
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
There should be a (legal) name and a refersto argument. See Help for the Add method as it refers to Names.
 
Upvote 0
Got it, Final Code is:

Code:
Sub DupRangeNames() 'assumes pre-existence of sheets: Front Page Block1 and Front Page Block2
Dim Cadd As String, FullNameData As String
For i = 1 To ActiveWorkbook.Names.Count
  Cadd = ActiveWorkbook.Names(i)
  Cadd = WorksheetFunction.Substitute(Cadd, "Block1", "Block2")
  FullNameData = Names(i).Name
  FullNameData = WorksheetFunction.Substitute(FullNameData, "Block1", "Block2", 1)
  FullNameData = WorksheetFunction.Substitute(FullNameData, "b1day", "b2day", 1)
  ActiveWorkbook.Names.Add Name:=FullNameData, RefersTo:=Cadd
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top