Hey guys, welcome back. So in this video, we're going to see how to get to the next row and that is the row after the last row on our data set. And we would want to do that in order to add new rows to our data set, for example. So how can we get the row number for the next row? Well, it's very simple, you could just do the same one here, the same formula for getting the last row, except that you're just going to add a plus one. So this formula for getting the last row yields an integer, which is the last row, if you add a plus one, two that you go to the next row, right, so then you can start typing values on the row that is the next row.
So in our case here, if you start typing values, we're going to start typing values on row number 20. So you could write for example, cells, the row index number is going to be nr, then comma one, we're going to type in the first column Which is the name we're going to type for example jack and then sells an r comma two, which is the day it's going to be equals date serial. Let's enter a random day 2016 oh 705 for example, I'm actually going to copy that here. So comma three is equal to, we're going to put an item so say 15. And then the one that is comma four, which is for the fourth column, let's say we're going to type the sales amount to be 100,000. So if you run this code, we actually going to go through it step by step here, and r is equal to 20.
This is the next row we're going to start executing these statements. So on the value for the next row and first column is going to be jack and then the date and then 15 and then 100,000. Okay, so this is how you can get the value for The next row is very easy. Now there is another way actually, that people use sometimes sub next row other way. That's great and use a procedure here. And what some other people do as well to go to the next row is actually using the range object.
So range for example here. And then remember guys, when the range object, we just entered a reference for the cell. So let's say we're going to enter range a, and then concatenate on that and the value of our, okay in this way, we got a range, for example, a 21, because the next row we're going to type on is a 21. So a 21 is going to be equal to Jason, whatever. And then we could do B and concatenated on an R is going to be date serial, whatever. 2016 Oh, 403 Or example, and then range C and N or N percent and or is equal to 12, for example, and then d m percent n or is equal to 50,000, for example, this is another way of actually referring to cells when you have variables, although it's less common way, and it's the less recommended way.
So using the cells collection object is better. But sometimes people do that. So they would refer to a cell if the row number is a variable, do just concatenate the column name, which is your column A, for example, on using the ampersand on the nr and the ampersand is actually used when you need to concatenate text, you know, a piece of text on another piece of text and we'll see that a lot actually in the course. And you do that in Excel and they normally Excel we need to concatenate a piece of text on a piece of text. You The M percent as well. You should be familiar with that.
Okay, so if you're on this code, we're going to have these values pop on, roll 21. Okay, so this is another way that people could write it. I'm just showing you that so that if you see in somebody else's code, you wouldn't feel that is weird. Okay, guys. So that's it for the next row. Thank you very much for watching this video and I'll see you on the next one.