View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Named Ranges: Can I do This? How?

Just to add to Bob's response...

If you wanted to use a worksheet level name:

Set shtSup1 = Sheets("Supplier")
with shtSup1
Set rng = .Range("C6,C16,C23,C36,C56")
rng.Name = "'" & .name & "'!Sup1_BCAPA_Ratings"
end with



Bob Phillips wrote:

Dim shtSup1 As Worksheet
Dim rng As Range

Set shtSup1 = Sheets("Supplier")
Set rng = shtSup1.Range("C6,C16,C23,C36,C56")
rng.Name = "Sup1_BCAPA_Ratings"

--
__________________________________
HTH

Bob

"Walter" wrote in message
...
shtSup1.Names.Add Name:="Sup1_BCAPA_Ratings", _
RefersTo:=Supplier!$C$6,Supplier!$C$16,Supplier!$C $23,Supplier!$C$36, _
Supplier!$C$56,Visible:=True

I want to add named ranges in my workbook with VBA. However, the range
that
I have is discontiguous as noted above. I can enter it in the
Insert/Name/Define and it works. How do I write the code so that it
compiles
in VBA? I keep getting an error. Supplier is the name of the worksheet.
I
am working in Excel 2003. Thank you!


--

Dave Peterson