+ Reply to Thread
Results 1 to 7 of 7

How do you use the Name property of the Range object?

  1. #1
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    How do you use the Name property of the Range object?

    I am trying to assign a name to a range:

    Please Login or Register  to view this content.
    I am getting an error saying "Object doesn't support this property or method."



    I have two questions:

    1. How do you assign a name to a range?
    2. How do you display that name in a Msgbox?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,193

    Re: How do you use the Name property of the Range object?

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do you use the Name property of the Range object?

    Hi,

    1.
    worksheets(1).Range("D4:D8").Name = "Revenue"

    2.
    MsgBox Range("D4:D8").Name.Name
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,193

    Re: How do you use the Name property of the Range object?

    Not sure if this is what you mean for the second part:

    Please Login or Register  to view this content.

    Regards, TMS

  5. #5
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: How do you use the Name property of the Range object?

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    1.
    worksheets(1).Range("D4:D8").Name = "Revenue"

    2.
    MsgBox Range("D4:D8").Name.Name
    Thank you sir. I'm fairly certain I tried your suggestion for #1, but it didn't work. But it works fine now.
    Regarding #2, it works but the MsgBox says Sheet1!Revenue instead of simply Revenue. Is there a way to display just Revenue?

  6. #6
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: How do you use the Name property of the Range object?

    Quote Originally Posted by Excel_vba View Post
    Thank you sir. I'm fairly certain I tried your suggestion for #1, but it didn't work. But it works fine now.
    I tried this with a two word name and got an error. But then I remember that a space isn't allowed in a Name. You need an underscore.
    Last edited by Excel_vba; 08-15-2013 at 07:27 PM. Reason: Edit.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do you use the Name property of the Range object?

    Re 2.

    Seems to work OK for me. Upload your workbook if it's still not showing just Revenue.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do you use the ListObjects property of the range object?
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2013, 05:48 PM
  2. How do you use the Worksheet property of the Range object?
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2013, 09:49 PM
  3. Using a range object as a property in a class
    By Lazhal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2010, 08:07 PM
  4. Range object lacks Value property
    By Raymond Langsford in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2006, 04:30 PM
  5. How to use Cells property to Range object?
    By deko in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-08-2005, 04:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1