Hey guys, welcome back. So in this video, we're going to hide a more complex example using the do loop. And we're going to solve this problem here using a do until and a do while as well. So as you can see here, I've got a list of the highest grossing movies, the movies with the highest earnings in 2016. And basically what I want to do using a dupe is to either write the word millionaire or billionaire in column D, depending on the movies earnings. So if the movies earnings are greater than or equal to 1 billion, I'd write the word billionaire.
And if you're less than 1 billion, then Adora, the word millionaire. And I want to do that using a do loop. So basically, here on this macro, the first step is I'm going to activate the movies sheet to make sure I work on the correct sheet and then I'm going to select cell D two, and then I'm going to do until the value of the active cell to offset zero comma negative one is equal to blank. And that is the value of the cell that is on the left hand side of column D. So basically the value of the cell in column C on the same row here, so I'm going to loop until there is nothing in the cell. So basically, I'm going to keep on looping, as long as I've got some earnings in column C, and when I don't have any earnings when a cell is blank, then I'm going to stop the loop.
Okay, so this is the condition for stopping the loop. And basically, there's an if statement here that says, if the value of the cell in column C, just one cell to the left of the cell in column D, that I'm sitting on is greater than or equal to 1 billion, then I'm going to set the cell in column D to be equal to billionaire else. I'm going to put the word millionaire, and then inside the loop as well. I'm gonna move one cell down to do the test again. So I'm going to move on to Sell down and then loop again and start doing the test again and put either billionaire or millionaire move on sell down, do the test again, until the value of the Sun column C is equal to a blank, that's when the loop stops. So I'm going to go through the loop step by step here.
So as you can see here, I've selected cell D two, I'm gonna do my testing, I put billionaire on there. And I'm going to loop again here, do it again, until I basically finish the loop. Okay, so, so the loop is finished because it tested the cell in column C here, cell C 12. And it found it blank. So this is why the loop has finished. So we've done it this way using the dual until we could do it using the do while as well, but I need to change the condition here so that the value of the cell does not equal to blank.
Okay, so I'm going to lose As long as the value of the song column c is not equal to blank, so if I just delete these cells again here and I run the macro step by step as well, and you can see here that I'm filling the cell here, using the do while instead of doing till a now when it actually tests the condition again, and it found that this cell is blank, so this condition is false. Okay, so it actually exited the loop, as you can see here, and we've ended the macro. So this is an example here that we've managed to do using the do until and the do while as well. So that's it guys for this example. Thank you very much watching this video. I'll see you on the next one.