How To Find The Last Row in Microsoft Excel 2010

In this article, you will learn how to find the last row using VBA.

Let us understand with an example:

Following is a snapshot of Sales Report wherein the last row can be identified as 10.
 
img1
 
In above example, the number of rows is quite less & we can manually figure out the number of last row; in case there is large number of rows & multiple sheets then, it will be a pain to find the last row & we require VBA code to help us.

 

Click on Developer tab

From Code group, select Visual Basic
 
img2
 
or press ALT + F11 shortcut key to launch VB Editor screen.

Click on Insert, and then on Module
 
img3
 
This will create new module.

Enter the following code in the Module
 
Sub LastRow()

LR = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row

MsgBox "The last row is "&LR

End Sub
 
img4
 
The result will be shown through Message Box
 
img5
 
In this way, you can get the last row of the worksheet using VBA code & now, we can use this code in writing larger codes for automation purpose.
 
 

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Visit Us On TwitterVisit Us On FacebookVisit Us On Google PlusVisit Us On Youtube