From the course: Excel: Learning VBA
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
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,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Repeat a task using a For…Next loop5m 6s
-
(Locked)
Step through all items of a collection using a For…Each loop4m 37s
-
(Locked)
Repeat a task using a Do loop5m 47s
-
(Locked)
Execute code conditionally using an If…Then statement6m 48s
-
(Locked)
Select which action to take using a Case statement3m 42s
-
(Locked)
Challenge: Add logic to your code2m 52s
-
(Locked)
Solution: Add logic to your code4m 40s
-
-
-
-
-
-