#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Named Range


Sub NewNamedRange(NR As String)
'Nr is sending a number like 2007
Dim aw As String 'used to name range
Dim aw1 As String 'used for range parameters
aw = "Sales" & NR
aw1 = "=" & "sales " & NR & "!$a$2:$i$2"

ActiveWorkbook.Names.Add Name:=aw, RefersTo:=aw1

End Sub

What am I doing wrong?

In the Immediate window
sales= "sales"
nr= "2007"
aw1 = "=" & "sales " & NR & "!$a$2:$i$2"
?aw1
=sales 2007!$a$2:$i$2

aw1 is correct but the named range becomes this
=sales '2007'!$A$2:$I$2


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Named Range

Try this

Sub NewNamedRange(NR As String)
'Nr is sending a number like 2007
Dim aw As String 'used to name range
Dim aw1 As String 'used for range parameters
aw = "Sales" & NR
aw1 = "=" & "'sales " & NR & "'!$a$2:$i$2"

ActiveWorkbook.Names.Add Name:=aw, RefersTo:=aw1

End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"C Brehm" wrote in message
.. .

Sub NewNamedRange(NR As String)
'Nr is sending a number like 2007
Dim aw As String 'used to name range
Dim aw1 As String 'used for range parameters
aw = "Sales" & NR
aw1 = "=" & "sales " & NR & "!$a$2:$i$2"

ActiveWorkbook.Names.Add Name:=aw, RefersTo:=aw1

End Sub

What am I doing wrong?

In the Immediate window
sales= "sales"
nr= "2007"
aw1 = "=" & "sales " & NR & "!$a$2:$i$2"
?aw1
=sales 2007!$a$2:$i$2

aw1 is correct but the named range becomes this
=sales '2007'!$A$2:$I$2




Reply
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
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
automatic range - named range give me circular reference... George Thorogood Excel Discussion (Misc queries) 0 February 22nd 07 07:53 PM
Array as a "named range" - formula ok in cells, but error as "named range" tskogstrom Excel Discussion (Misc queries) 11 December 28th 06 04:44 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Can I use named range in data range box when creating pie chart? BJackson Charts and Charting in Excel 2 August 17th 05 05:37 PM


All times are GMT +1. The time now is 08:21 PM.

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

About Us

"It's about Microsoft Excel"