How To Find The Last Used Cell in a Row in Microsoft Excel 2010

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

Let us understand with an example:

We can see that there are 3 columns of data in our example & we want to find out the last used cell in row number 1. Refer below snapshot.
Click on Developer tab

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

Click on Insert then Module
This will create new module.

Enter the following code in the Module


Sub LastCellInRow()

Dim LastCol As Long

    With ActiveSheet

        LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column

    End With

    MsgBox "The last column is " & LastCol

End Sub
The result will be shown through Message Box
In this way, you can get the last used cell in a row, using VBA code.

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 Youtube