We're going to use our newly found skill of using loops and we're going to use it with our first initial
database where we have the names and the titles the dates of the sale and the sale amounts.
So what we're going to do now is we're going to basically build our first report one step at a time
all development to get into the Visual Basic Editor.
Let's do a simple loop and what are our starting parameters.
We know it's going to start on two.
So our FOR FOR NEXT loop is obviously going to be for X or for whatever equals to all the way to whatever
our last row is.
So we need to combine the skills that we've learned so far we need to get the last row and then we'll
reference that as the last.
Instead of putting typing 10 to 10 we'd put from 2 to whatever our variable is that contains our last
row.
So all this combined can bind those two skills.
We're going to create a new set we're going to call it my first report and very simply for the first
one we're going to do it in a message box in the next video we're going to show you how to do that in
an actual different sheet.
So you can have a printable report very easy.
So first things first.
Let's go ahead and let's go ahead and get our last row.
So let's go and get them.
Now let's call it the last row equals and we're going to say
we're going to say cells and we're going to use rows not count.
Comma 1 using the in function.
We're going to go x l up and we're going to extract the row.
That's our last row and then we're going to say for X equals 2 to our last row
you are next X hit up hit tab and we're ready to go.
So what we want to do in this case I want us to do a report for anything over two hundred dollars.
So that's going to be analyzing column for let's see if 8 and get started.
So last row we see is 11.
That's good.
X is going to be 2 all the way to 11 because that's our last row variable.
Before we begin let's play this out we're going to say if number the If Then statement you can say if
cells using RHO X which is going to be to first if cells row X and column 4 which is the money is greater
than or equal to 200 bucks then in hit enter tab and other enter in I'm going to shift tab and type
and if that way it won't give us errors later.
So let's just take a look here once we initiate our for next loop it will actually give X the value
of 2.
And so now we'll have to call him for which is cell D for the value of 482 is that greater than equal
to 200 Yes.
So that would be our first yes to this question.
So let's get maybe their name let's get their name in a message box.
So we're going to say let's say my message.
That's another variable.
My message equals whatever my message was.
As well as am whatever is in that cell only We're going to use cells the current row or we're going
to take.
We're going to take column one which has their name.
So just to show you what that does.
Let's see it's going to be empty right now but we're going to combine that with Heraldo which is his
name.
Then the next one let's see that's two and a 57 still greater than 200.
So this would be her older Heraldo and Makow.
So now will say Heraldo.
MCCALL Well I don't really like that you could have a space.
But what I would prefer to do is to add a new line and I'll show you how to do that.
You say ampersand space.
VB new line.
Add another ampersand to join that and the VB new line is a built in variable that tells it to create
a new line in the message box.
So if we start over it Effie.
So first we have Heraldo then we have Heraldo new line in Macau.
It doesn't look like it but if I hit F5 and it ran.
So at the very end when you're done with all your looping and outside of the loop we're going to say
message box and it's going to be my m s g Now my m s g is just a random word you could put the word
blah here and here and here or any word you want it for that variable and it would do a message box
or whatever is contained in there.
So let's stop it right here.
Let's hit F5 runs all the way to the end and let's show you what the message box looks like her although
McCowen June Dan Amy Terisa and Fernando those are the only ones that are above 200.
So if you want to make that a little bit more strict you could see who all has more than 400 by doing
this.
And let's hit F5 now Heraldo And Dan in let's see Heraldo you more than 400 and Dan more than 400.
So that is correct.
In the next video we're actually going to show you how to make this a little bit more dynamic using
an input box.