How To Find The Last Used Cell in One Column in Microsoft Excel 2010

In this article, you will learn how to find the last used cell in one column.

Let us understand with an example:

We can see the last row number is 14 in our example but we want to find out the last used cell in column A. Refer below shown snapshot.
 
img1
 
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 LastCellInColumn()

Dim LastRow As Long

    With ActiveSheet

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

    End With

    MsgBox “The last row is ” & LastRow
End Sub
 
img4
 
The result will be shown through Message Box
 
img5
 
To find the last used cell in column B, we will use the following code:

Sub LastCellInColumn()

Dim LastRow As Long

    With ActiveSheet

        LastRow = .Cells(.Rows.Count, “B”).End(xlUp).Row

    End With

    MsgBox “The last row is ” & LastRow

End Sub

We have only changed the column number from A to B (nothing much)

We will get result as 14. Refer below snapshot of message box
 
img6
 
In this way, you can get the last used cell in one column of the worksheet, using VBA code.
 
 

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

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