+ Reply to Thread
Results 1 to 4 of 4

Relative cell position in its own CurrentRegion

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    no
    MS-Off Ver
    Excel 2003
    Posts
    2

    Relative cell position in its own CurrentRegion

    Hello!

    I am back to VBA for a personal project and I am having a hard time to get what I want with ranges.

    I want to let the user choose a cell, expand it to its CurrentRegion to get the table in which the cell is located, and then I am looking for a way to get the relative position of the cell in this new Range.

    First of all, I am having an error when trying to set a variable as the CurrentRegion range
    Dim myTable As Range
    myTable = ActiveCell.CurrentRegion

    I tried various ideas (using Excel.Range variable type, using Range(ActiveCell.CurrentRegion), using ActiveCell.CurrentRegion.Cells, etc...) but without any success: I always end up with "object variable or with block variable not set".

    In the end, I would like to obtain the relative position of the cell in its current region: if the cell C5 is in CurrentRegion A2:F12, I would like to know that it is in the 4th row and 2nd column. Is there an easy way to work with cell/range properties in a new reference (not the whole sheet)?

    If anyone has any idea on that matter, I would be glad to learn more about it.

    Thank you,
    B
    Last edited by qsdf; 09-06-2016 at 03:31 PM.

  2. #2
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Relative cell position in its own CurrentRegion

    Please Login or Register  to view this content.
    Frob first, tweak later

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Relative cell position in its own CurrentRegion

    Maybe this:

    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  4. #4
    Registered User
    Join Date
    08-01-2012
    Location
    no
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Relative cell position in its own CurrentRegion

    Thank you!

    I was missing the "Set" at the beginning.

    And thank you for the relative position part as well, it's going to be useful!

+ 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. [SOLVED] Average formula with relative cell reference and position
    By Buster^ in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-01-2014, 05:19 PM
  2. Paste info to cell in position relative to a named cell-Simpler than it sounds
    By mariosmk555 in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 05-06-2014, 01:07 AM
  3. Replies: 2
    Last Post: 04-04-2012, 11:00 AM
  4. relative position of active cell over multiple sheet
    By endoskeleton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2011, 09:28 AM
  5. Change Active Cell but not it's relative position
    By johngombola in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2009, 05:39 AM
  6. Relative Cell position NOT working with or without macro
    By Scratching my Head in forum Excel General
    Replies: 6
    Last Post: 05-30-2005, 02:05 PM
  7. Create cell formula from a relative position
    By Geoff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2005, 05:19 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