From the course: Excel: Learning VBA

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Solution: Add logic to your code

Solution: Add logic to your code - Microsoft Excel Tutorial

From the course: Excel: Learning VBA

Solution: Add logic to your code

(upbeat music) - [Instructor] In the previous movie, I gave you a series of challenges relating to logic within Excel VBA. In this movie, I will show you how I might solve them. My sample file is 03_07_Solution, and you can find it in the Chapter Three folder of the Exercise Files collection. Again, on Sheet1, we have the data we'll be working with, and we're focusing on the data starting in cell C3. So we're only looking at shipping charges. With that in mind, I'll press Alt + F11 to move to the visual based editor, and in the ForNextChallenge subroutine at the top, I asked you to create a For...Next loop to read the seven worksheet values into the array. Now, I gave you a hint and a reminder on how this needs to work when I created the variable here. I used the number 6, because for an array, you want to have one less than the total number because you start counting from zero. So seven elements would be 0, 1, 2, 3, 4,…

Contents