+ Reply to Thread
Results 1 to 3 of 3

Thread: Return the row value / position within a range?

  1. #1
    Registered User
    Join Date
    06-01-2011
    Location
    Swindon, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Return the row value / position within a range?

    Hi

    I am having an issue with returning the the row value / position within a range. For example, I have returned the row value for the worksheet:

      Dim ActiveRowCount As Integer
    
           ActiveRowCount = ActiveCell.Row 'In this example we will say it returns 18
    But am failing miserably with getting the value from a range. The range is assigned as below:

     Set myRange = ActiveCell.CurrentRegion
            RowCount = myRange.Rows.Count ' In this example we say it returns 15
    I then try to return the row value of the active cell within the range (myRange), using the below:

    myRangeActiveRowCount = myRange.Application.ActiveCell.Row
    The above returns 18, which is the return value for the active cell in the worksheet and not within the range. In the above example the return value for the range should have been 7.

    Any help would be much appreciated.
    Last edited by NBVC; 06-01-2011 at 10:50 AM.

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,639

    Re: How do you return the row value / position within a range?

    Please use code tags for code snippets... I added them this time for you....
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Return the row value / position within a range?

    The row position of the active cell relative to myrange is

    myRow = ActiveCell.Row - myRange.Row + 1
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0