Consulting

Results 1 to 8 of 8

Thread: Solved: Finding last row of a column

  1. #1
    VBAX Contributor
    Joined
    Apr 2006
    Posts
    100
    Location

    Solved: Finding last row of a column

    I am pulling data from another workbook, and I need to know the last row of any worksheet in that workbook. There will be empty row before that last row. I need to find the total number of rows of a sheet.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is it the last row in a particular column, or the last last row of all columns.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Apr 2006
    Posts
    100
    Location
    The column will always be D I am just want to find the last row of that column.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    With Worksheets("Sheet1")

    LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Contributor
    Joined
    Apr 2006
    Posts
    100
    Location
    Sorry did not work. I am posting a example workbook with data populating sheet1. The last row will always be moving on every sheet in different workbooks.

  6. #6
    VBAX Contributor
    Joined
    Apr 2006
    Posts
    100
    Location
    I got the answer Iwas looking for.

    wbk.Sheets(I).Range("D65536").End(xlUp).Row

    Thanks for the help.

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,093
    Location
    How does your solution do what you asked in your first post?

    I am pulling data from another workbook, and I need to know the last row of any worksheet in that workbook. There will be empty row before that last row. I need to find the total number of rows of a sheet.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  8. #8
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by SeanJ
    I got the answer Iwas looking for.

    wbk.Sheets(I).Range("D65536").End(xlUp).Row

    Thanks for the help.
    That is what the reply in Post 4 does, when suitably qualified as per your example, but it will also work in Excel 2007 which can have rows greater than 65536.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •