View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default What is wrong with this code to name a worksheet range

Your original code expects 'aWS' to be a string, ie the name of a worksheet
in the implicitly referenced Activeworkbook, though not necessarily the
activesheet.

If you've already set a reference to the activesheet, which is what you say
aWS is, -

aWS.Names.Add Name:="PlusMinusCount", RefersTo:="="&count

In passing probably better not name variables same as key-names, such as
'count'

Regards,
Peter T



"Barb Reinhardt" wrote in message
...
aWS is the activesheet.
Count is an integer variable that's defined earlier in the code.

"Peter T" wrote:

What's 'aWS' and 'count'

Regards,
Peter T

"Barb Reinhardt" wrote in

message
...
Worksheets(aWS).Names.Add Name:="PlusMinusCount",

RefersTo:="="&count

Thanks