+ Reply to Thread
Results 1 to 6 of 6

Find the last row.

  1. #1
    Forum Contributor
    Join Date
    10-27-2006
    Location
    United Kingdom
    MS-Off Ver
    EXCEL 2003 (2007 at home)
    Posts
    517

    Find the last row.

    I think I've seen this question answered before,
    but I couldn't find the relevent thread so I'll ask it again

    How can I find the last "used" cell in a column?

    The value might be text, or numeric.

    I am importing data which may include 10 rows or 10000 rows,
    I would like to have a cell (on sheet2) that tells me
    (and any formulas I might use for analysing this data)
    how many rows there are.

    Mark.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    Here's a collection of formulas to return the last value in a COLUMN
    depending on the type/structure of data.
    1. If you have no blank rows in between use
    =OFFSET($A$1,COUNTA($A:$A)-1,0)

    2. If you have blank rows in between try the following depending of the
    type of values in your column:
    2.a. If you have ONLY text values in column A try
    =INDEX(A:A,MATCH(REPT("z",255),A:A))


    2.b. If you have ONLY numbers in column A:
    =INDEX(A:A,MATCH(9.99999999999999E307,A:A))
    or
    =LOOKUP(9.99999999999999E307,A:A)


    2.c. If you have BOTH types (text and values), but AT LEAST one text
    and one numeric entry
    =INDEX(A:A,MAX(MATCH(9.99999999999999E307,A:A),MATCH(REPT("z",255),A:A)
    ))


    2.d. If you don't know the type of data use the following array
    function (entered with CTRL+SHIFT+ENTER)
    =INDEX(A:A,MAX(IF(ISBLANK(A:A),0,ROW(A:A))))


    2.e If you don't want to count formula results like ="" as entry adapt
    2.d. as follows:
    =INDEX(A:A,MAX(IF(A:A<>"",0,ROW(A:A))))


    Enjoy

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723
    mark,

    this will do it it is set to column A
    Please Login or Register  to view this content.
    STEVE

  4. #4
    Forum Contributor
    Join Date
    10-27-2006
    Location
    United Kingdom
    MS-Off Ver
    EXCEL 2003 (2007 at home)
    Posts
    517

    Smile Thank You

    One of those should do the trick,
    Thanks.
    Mark.

  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    for VBA coding ...

    To Select Last Row used, using Column A as the reference Column

    LastRow = Cells(Cells.Rows.Count,"A").End(xlUp).Row

    To Find 1st Empty row, using Column A as the reference Column

    Range("A65536").End(xlUp).Offset(1, 0).Select

    or

    Range("A1").End(xlDown).Offset(1,0).Select


    HTH
    Carim

  6. #6
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by Mark@Work
    One of those should do the trick,
    Thanks.
    Mark.
    nice collection, if all else fails set a function on

    LastRow = ActiveSheet.Range("A65536").End(xlUp).Row

    ---
    Si fractum non sit, noli id reficere.

+ 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