+ Reply to Thread
Results 1 to 11 of 11

how do i refer to a named cell in vba?

  1. #1
    Registered User
    Join Date
    11-05-2010
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    59

    how do i refer to a named cell in vba?

    e.g. i name a cell "hello"
    i would like to assign a vaule 2 to that cell, what will be the correct vba syntax to perform hello =2 ?

    thanks

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: how do i refer to a named cell in vba?

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    11-05-2010
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: how do i refer to a named cell in vba?

    thanks a lot,
    If i name instead multiple cells(range) as Hello,
    Could I refer to each cell using [Hello](i) = i?
    just like when we did range("Hello")(i) to refer to a certain cell in the range
    Last edited by DonkeyOte; 01-07-2011 at 10:21 AM. Reason: removed unnecessary quote

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: how do i refer to a named cell in vba?

    Do you mean create a range that contains multiple cells, like a table?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    11-05-2010
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: how do i refer to a named cell in vba?

    yeh, like naming range("a1","c6") as hello

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: how do i refer to a named cell in vba?

    Something like this will work in a table say A1:C6.
    Please Login or Register  to view this content.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: how do i refer to a named cell in vba?

    Quote Originally Posted by yellowpower
    Could I refer to each cell using [Hello](i) = i?
    If as I suspect you're referring exclusively to Evaluate then no, not with the shorthand notation assuming i is meant to reflect a variable.

    If i is a constant:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-05-2010
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: how do i refer to a named cell in vba?

    Great! thanks

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: how do i refer to a named cell in vba?

    You could however use:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  10. #10
    Registered User
    Join Date
    11-05-2010
    Location
    london, england
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: how do i refer to a named cell in vba?

    thats very helpful. tx!

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,972

    Re: how do i refer to a named cell in vba?

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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