Consulting

Results 1 to 2 of 2

Thread: Naming a selected range

  1. #1

    Naming a selected range

    I get errors while running this code (despite the fact that the type of the selection indeed is Range). Why?

    [VBA]
    ' the type is Range
    MsgBox TypeName(Selection)
    Dim sel As Range
    ' here i get an error
    sel = Selection
    [/VBA]

  2. #2
    VBAX Expert
    Joined
    Feb 2005
    Location
    Nanaimo, British Columbia, Cananda
    Posts
    568
    Location
    Hi Chamster,

    You need to use the 'Set' keyword for an object, eg a Range


    Set sel = Selection
    Cheers,

    dr

    "Questions, help and advice for free, small projects by donation. large projects by quote"

    http:\\www.ExcelVBA.joellerabu.com

Posting Permissions

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