View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Named Ranges: Can I do This? How?

Try it this way...

shtSup1.Names.Add Name:="Sup2"_BCAPA_Ratings", RefersTo:=Range( _
"Supplier!$C$6,Supplier!$C$16,Supplier!$C$23,Suppl ier!$C$36,Supplier!$C$56"), _
Visible:=True

Note that the Range function is used to create the RefersTo reference and that its argument is a String value (hence, the quote marks).

--
Rick (MVP - Excel)


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