How To Find The Last Row In Excel VBA

In this post I am going to show you how you can find the last row in excel vba, so you can enter your new data.

On the previous screen I have a list of random names I generated from https://www.generatedata.com/

When the button “View/Edit Records” is clicked, we’re launching a UserForm which allows us to move back and forth through the records, edit, and add new ones.

This is what happens when the UserForm is clicked:

Cell A2 is selected and the textbox shows the value of Cell A2.

These are the buttons which control record navigation:

Again, we have a modular scope variable because we need to know the row being referenced as long as the form is open, and if we just form it in the procedure, the scope will only be when one of the buttons are clicked.

The “New” button is really the jist of this post.

The plan is:
**First find the last cell used, then find the row of the cell.

***We could move from the “top down”, or the “bottom up”.

With the “top down” approach, we’ll find the next available cell, but the blank cell may be between 2 already used cells.

In my opinion, we can move to the last row on the worksheet, and then upwards to find the last used cell.

This is the better option IMO.

Now that we found the last row, we can enter new data:

This is pretty simple, we are just setting the cell value = to the form value.

Here is all the code:

So that’s how to find the last row in Excel VBA.

Let me know if you have any questions.

Use this form to send me a message:

I consent to having this website store my submitted information so they can respond to my inquiry. See our privacy policy to learn more how we use data.
 

****************************************************

Please remember to subscribe to my youtube channel

Been helped? Get these!

Facebooktwittergoogle_plusredditpinterestlinkedinmail