Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    multi area range name (2000)

    I want to create a named range covering non-contiguous cells.
    I've tried the following

    ActiveWorkbook.Names.Add Name:="GreenCells", RefersTo:= _
    Selection

    '''This works fine. Then I want to select the next area and add those
    '' selected cells to the named range:

    Range(Activecell.Offset(20,0),Activecell.Offset(30 ,0)).Select
    ActiveWorkbook.Names.Add Name:="GreenCells", RefersTo:= _
    Range("GreenCells") & Selection

    This produces a Type Mismatch Error

    Suggestions?

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: multi area range name (2000)

    How about this?

    ActiveWorkbook.Names.Add Name:="GreenCells", _
    RefersTo:=Selection

    ActiveWorkbook.Names.Add Name:="GreenCells", _
    RefersTo:=Union(Selection, _
    Range(ActiveCell.Offset(20, 0), ActiveCell.Offset(30, 0)))

    Steve

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: multi area range name (2000)

    Keep in mind, that the maximum number of areas a name can hold is about 225.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •