LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding Range Names

As a test, open a new workbook and run this code:

Sub ABCTest()
ActiveWorkbook.Names.Add Name:="Name2", _
RefersTo:="Sheet1!$A$1:$A$10"
' Mix A1/R1C1 and omit equal sign
ActiveWorkbook.Names.Add Name:="Name3", _
RefersToR1C1:="Sheet1!$A$1:$A$10"
' Should work
ActiveWorkbook.Names.Add Name:="Name4", _
RefersTo:="=Sheet1!$A$1:$A$10"
End Sub

Name2 and Name3 will exhibit the behavior you describe (with quotes). Name4
works correctly

I had this initially
' Mix A1 and R1C1
ActiveWorkbook.Names.Add Name:="Name1", _
RefersToR1C1:="=Sheet1!$A$1:$A$10"

But it raised an error although it seems to me in earlier versions this
caused the same problem.

--
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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting email address names in a range of cells to real names John Excel Worksheet Functions 1 May 19th 10 03:44 PM
adding range names SheriTingle Excel Discussion (Misc queries) 2 July 12th 05 03:52 PM
Adding Range Names John Excel Worksheet Functions 1 January 18th 05 11:56 AM
Adding Range to Worksheet Names Collection Keith Willshaw Excel Programming 2 March 5th 04 09:17 AM
Adding and deleting Range Names Paul Excel Programming 1 October 1st 03 10:56 AM


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"