+ Reply to Thread
Results 1 to 3 of 3

Cell number in range

Hybrid View

  1. #1
    Registered User
    Join Date
    08-06-2013
    Location
    Quebec
    MS-Off Ver
    Excel 2013
    Posts
    31

    Cell number in range

    Hey all,

    If I have a range, let's say myRange = ("B2:M13"), is there anyway to link the cells to a single number, not coordinates?

    For example:
    B2 would be 1, B3 would be 2, C2 would be 13, M13 would be 144.

    This way, I could refer to a cell in the range using something like myRange(1) for 1st cell ** the range.

    Thank you so much!

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Cell number in range

    Using your posted scenario
    and
    A1: a number between 1 and 144, inclusive

    This VBA User Defined Function returns the cell address referenced by cell A1
    Function MyCell(cCell As Range) As String
    Dim RowRef As Long
    Dim ColRef As Long
    Dim rng As Range
    Set rng = [$B$2:$M$13]
    
    RowRef = cCell Mod 12
    ColRef = Int(cCell / 12) + 1
    MyCell = rng.Cells(RowIndex:=RowRef, ColumnIndex:=ColRef).Address
    
    End Function
    Use that function this way on the sheet with the range:
    Formula: copy to clipboard
    =MyCell(A1)
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    08-06-2013
    Location
    Quebec
    MS-Off Ver
    Excel 2013
    Posts
    31

    Re: Cell number in range

    Perfect! Thank's a lot!

+ 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. Find a string withing cell range and return cell number
    By visak in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-16-2015, 09:19 PM
  2. [SOLVED] assigning number to text in a cell then adding a range together in another cell
    By joe malik in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-12-2013, 01:12 AM
  3. Replies: 1
    Last Post: 07-18-2013, 10:11 AM
  4. [SOLVED] check if number in once cell exists in a range of cells and if yes, format another cell
    By beaujolais44 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-16-2013, 07:23 AM
  5. [SOLVED] How to Specify a range using another cell vale instead of row number
    By ramana in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-29-2005, 05:05 AM

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