+ Reply to Thread
Results 1 to 5 of 5

Return the first cell reference from a named list

Hybrid View

  1. #1
    Registered User
    Join Date
    09-13-2008
    Location
    Australia
    Posts
    12

    Return the first cell reference from a named list

    i'm trying to return the reference of the first value of a named list. For example
    i have the list "names" which is from C5:C7.
    C
    5 Ben
    6 John
    7 Daniel
    8

    I have another worksheet which needs to use the cell address of the first name in the
    named list "names". ie return "C5". How do i do this?

    I Can use INDEX(names,1) to get the value of the first cell but i need the cell reference.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re : Return the first cell reference from a named list

    How about this:

    =ADDRESS(ROW(names);COLUMN(names))
    =ADDRESS(ROW(names)+1;COLUMN(names))
    =ADDRESS(ROW(names)+2;COLUMN(names))
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Registered User
    Join Date
    09-13-2008
    Location
    Australia
    Posts
    12
    works great on the worksheet. however doesn't work in VBA. It says sub or function not defined and points to "Row". my function needs to return a range "ADDRESS(ROW(names),COLUMN(names)):ADDRESS(ROW(names)+2,COLUMN(names))" as a string.
    how would i do this in VBA?
    Last edited by zinny; 09-18-2008 at 08:19 AM.

  4. #4
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: Return the first cell reference from a named list

    this is actually very simple
    Function ReturnFirstAddressAsString(names As Range) As String
      ReturnFirstAddressAsString = CStr(names.Address) '$C$5:$C$7
      'ReturnFirstAddressAsString = CStr(names.Resize(1, 1).Address) '$C$5
    End Function
    Call this function as
    NameStr = ReturnFirstAddressAsString(range("names"))

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    In a Spreadsheet formula =OFFSET(myList,0,0,1,1) returns the first cell of myList as a range.
    In VB
    Range("myList").Cells(1,1)
    does the same thing.

    If the address of that cell is needed (rather than the cell itself), the spreadsheet function ADDRESS or the property .Address would be used.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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. Need an iterative cell entry and print for entire list of values.
    By jwhitwell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2008, 01:22 PM
  2. VBA to rename worksheet based on cell reference on another worksheet
    By Sandi99 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2008, 01:46 PM
  3. Skip Circular Reference...
    By harishs in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-18-2008, 11:10 AM
  4. Offset on a named cell ???
    By Herve_Rob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2007, 10:07 AM
  5. Indirect Formula to return Text from one sheet to cell in another sheet
    By lou031205 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-04-2007, 02:51 PM

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