View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Adding Range Names

I'm now getting a runtime error:
A B
2 chtlen =12
3 ActItms_ChartLabel
=OFFSET(ActItms!$B$33,0,0,1,min(chtlen,COUNTA(ActI tms!$33:$33)))

The error is on the following line:

ActiveWorkbook.Names.Add Name:=rangename, RefersToR1C1:="=" & seriesrange

"Tom Ogilvy" wrote:

I would have thought you would need to do:

ActiveWorkbook.Names.Add Name:= rangename, RefersToR1C1:="=" & seriesrange

if that is what you wanted to do.

--
Regards,
Tom Ogilvy

"Barb Reinhardt" wrote in message
...
I now have the following:

Dim lastrow
Dim rangename
Dim seriesrange
Dim CurBook
Dim i

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(" b" &
i).Value
Debug.Print rangename; seriesrange
ActiveWorkbook.Names.Add Name:="=" & rangename,

RefersToR1C1:=seriesrange
Next

A2: chtlen
B2: '=12

Thanks,
Barb