RE: End(xlDown) function

Discussion in 'Microsoft Excel Programming' started by Gary''s Student, May 10, 2009.

  1. Function LastRowNum()
    Application.Volatile
    Set r = Range(Application.Caller.Address)
    LastRowNum = r.End(xlDown).Row
    End Function

    --
    Gary''s Student - gsnu200852


    "John" wrote:

    > I have the following function to return the last row number in a column of
    > numbers:
    >
    > Function LastRowNum()
    > Application.Volatile
    > LastRowNum = ActiveCell.End(xlDown).Row
    > End Function
    >
    > Problem, I want it to return the last row number starting from the cell the
    > function is in, not starting from the active cell. ActiveCell obviously has
    > to come out, but what do I replace it with?
    >
    >
    >
     
    Gary''s Student, May 10, 2009
    #1
    1. Advertisements

  2. This could cause trouble if the function is used in different sheets. The
    unqualifed Range() will refer to the activesheet--not the sheet that contains
    the formula.



    Gary''s Student wrote:
    >
    > Function LastRowNum()
    > Application.Volatile
    > Set r = Range(Application.Caller.Address)
    > LastRowNum = r.End(xlDown).Row
    > End Function
    >
    > --
    > Gary''s Student - gsnu200852
    >
    > "John" wrote:
    >
    > > I have the following function to return the last row number in a column of
    > > numbers:
    > >
    > > Function LastRowNum()
    > > Application.Volatile
    > > LastRowNum = ActiveCell.End(xlDown).Row
    > > End Function
    > >
    > > Problem, I want it to return the last row number starting from the cell the
    > > function is in, not starting from the active cell. ActiveCell obviously has
    > > to come out, but what do I replace it with?
    > >
    > >
    > >


    --

    Dave Peterson
     
    Dave Peterson, May 11, 2009
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Tokash

    Selection.End(xlDown) with Rows selected

    Tokash, Aug 19, 2003, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    1,505
    Karen
    Aug 19, 2003
  2. norman

    Selection.End(xlDown) with Rows selected

    norman, Aug 19, 2003, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    587
    norman
    Aug 19, 2003
  3. reclusive monkey

    ActiveCell.End(xlDown).Select not working consistently

    reclusive monkey, Oct 8, 2003, in forum: Microsoft Excel Programming
    Replies:
    2
    Views:
    738
    reclusive monkey
    Oct 13, 2003
  4. jonH
    Replies:
    3
    Views:
    26,816
  5. Tom Ogilvy

    Re: Why doesn't Selection.End(xlDown).Select always work?

    Tom Ogilvy, Aug 3, 2004, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    1,927
    Tom Ogilvy
    Aug 3, 2004
  6. R.VENKATARAMAN

    repeated end(xldown)

    R.VENKATARAMAN, Dec 26, 2005, in forum: Microsoft Excel Programming
    Replies:
    6
    Views:
    409
    Doug Glancy
    Dec 28, 2005
  7. vedpatel

    Unable to use Range.End(xlDown) method

    vedpatel, Feb 28, 2006, in forum: Microsoft Excel Programming
    Replies:
    6
    Views:
    1,052
    Guest
    Mar 1, 2006
  8. JDB
    Replies:
    1
    Views:
    1,598
Loading...