View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Adding Range Names

Don't use ReferstoR1C1 when you are using A1 addressing. Also, append an
equal sign

RefersToR1C1:=seriesrange

should be

RefersTo:="=" & seriesrange

make sure ampersands are separated on each side with a space.

--
Regards,
Tom Ogilvy

"Barb Reinhardt" wrote in message
...
Tom,

I now have this as my code:

Dim lastrow
Dim rangename
Dim seriesrange
Dim CurBook
Dim i
Dim sht

CurBook = Application.ActiveWorkbook.Name
lastrow = Worksheets("RangeName").Cells(Rows.Count, "a").End(xlUp).Row
Debug.Print lastrow
For i = 2 To lastrow
rangename = Workbooks(CurBook).Worksheets("RangeName").Range(" a" &
i).Value
seriesrange = Workbooks(CurBook).Worksheets("RangeName").Range(" c" &
i).Value
sht = Workbooks(CurBook).Worksheets("RangeName").Range(" d" & i).Value
Debug.Print rangename; seriesrange; sht
'range name can't have a "'" or a "-" or a "%" or a " " or a "." or

"("
or ")" or "+"
'Added the following for possible use later
'Sheets(sht).Activate
ActiveWorkbook.Names.Add Name:=rangename, RefersToR1C1:=seriesrange
'Exit Sub
Next

My problem is that when I look at the range names, they look like this:
="OFFSET(ActItms!$B$33,0,0,1,min(chtlen,COUNTA(Act Itms!$33:$33)))"
instead of
=OFFSET(ActItms!$B$33,0,0,1,min(chtlen,COUNTA(ActI tms!$33:$33)))

What do I need to change? I assume it's something in the
ActiveWorkbook.Names line, but am not sure what.

Thanks,
Barb