+ Reply to Thread
Results 1 to 21 of 21

Get the last used of Row

  1. #1
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Get the last used of Row

    hi all,

    good days.


    how to get the last used of row for the range of data (A:W).
    if i had draw border to row 300.


    'LastRow = Cells(Rows.Count, 1).End(xlUp).Row (this 1 is only can count one column only)
    ''LastRow = ActiveSheet.UsedRange.Rows.Count (this 1 get the lastrow = 300 because i draw the border even there is blank)


    i want to count the last used of row for the range of data which exclude the border i draw to 300

    hope can get help from your all.

    thank you~

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Get the last used of Row

    Perhaps the following will do?
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Get the last used of Row

    Sorry, I may have mis-understood this.
    i want to count the last used of row for the range of data which exclude the border i draw to 300
    So if Row 300 hundred has a border and there's a row 301 without a border, you want the variable lRow to be 301?

  4. #4
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    thank you,

    but still cannot get the correct last used row.

  5. #5
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    if i only fill in some of the cell until row 25, then it show the last row as 25.
    even i had draw the border to row 300

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Get the last used of Row

    The code I provided you will set the range that is used. If you just want the last row number then
    Please Login or Register  to view this content.
    Did you change the
    Please Login or Register  to view this content.
    to reference the sheet in your workbook that you want to reference? For instance if you want to reference sheet 1 then
    Please Login or Register  to view this content.
    The code I gave you was referencing sheet 2.

  7. #7
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    yes, i change to sheet 1..
    the code you give me cannot count the correct last used row.

    i only want to know the last used row.

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Get the last used of Row

    Perhaps you should upload a mock workbook.
    the code you give me cannot count the correct last used row.
    It can and does but obviously there are issues in your workbook that don't agree with the code.

  9. #9
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    i am using office 2010. it just a normal workbook.
    please help~

    thank you.
    Last edited by ccs1981; 06-18-2013 at 09:26 AM.

  10. #10
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Get the last used of Row

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  11. #11
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    Please Login or Register  to view this content.
    actually i want the last used row to check some of the required column.
    Last edited by ccs1981; 06-18-2013 at 09:55 AM.

  12. #12
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Get the last used of Row

    I don't understand why you are not providing a workbook. I don't particularly like guessing all day when it comes to people's requirements. First you want rows now you want columns. Please, upload a mock workbook with a before and after scenario. If you do not, I will not bother any more.

  13. #13
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    sorry, i typo error.
    i want the last used row instead of last used column.

  14. #14
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    i upload here my workbook.


    My coding at ThisWorkbook.
    Last edited by ccs1981; 06-19-2013 at 03:54 AM.

  15. #15
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Get the last used of Row

    Thank you. Which sheet do you want this to run on?

  16. #16
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    the script is running when i want to close the workbook to ensure some of the column is required key in.
    it does not allow blank when try to save and close the workbook.

  17. #17
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Get the last used of Row

    So, sheet 1, where there is only 1 row used? LastRow is working perfectly in that scenario.

  18. #18
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    yes, you can simply insert any data into the cell.

  19. #19
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Get the last used of Row

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  20. #20
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Get the last used of Row

    Hi, patel45,

    "great" stuff: LR gets the highest row number by default (starting from row 1 as stated), and your loop is obsolete.

    @ccs1981:
    if your range starts with row 2 while there is only the heading available you will alwas get a notification. Maybe change your code to read
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Last edited by HaHoBe; 06-18-2013 at 12:05 PM. Reason: change of code added
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  21. #21
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    Re: Get the last used of Row

    thank you so much.

    it solved. Really appreciate it. ^^

+ 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