From the course: Excel: Learning VBA
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Define variables, constants, and calculations - Microsoft Excel Tutorial
From the course: Excel: Learning VBA
Solution: Define variables, constants, and calculations
(upbeat music) - [Instructor] In the previous movie, I gave you a series of challenges relating to variables. And in this movie I will show you how I solve them. This isn't the only solution, but it is one way to do it. I have opened my sample file 02_10_Solution. You can find it in the chapter two folder of the exercise files collection. And I'll look at my five bits of data here and then press Alt F11 to move to the Visual Basic Editor. So here, in the top subroutine for declaring a variable, I ask you to declare a variable named current sales, or currency sales, as the currency type, and also to use it in the message box. So here I have currency sales as currency, and the key word that you need to use to declare the variable is "dim" for dimension. And below that I have my message box that will display currency sales or just sales. So I'll go ahead and press F5 to run this code and I get $34,983.32. That is the value in…
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
-
-
-
-
(Locked)
Introduce Excel VBA data types4m 5s
-
(Locked)
Declare variables and require declaration before use5m 27s
-
(Locked)
Manage variable scope3m 50s
-
(Locked)
Define static variables and constants5m 42s
-
Create a calculation using mathematical operators5m 10s
-
(Locked)
Define arrays7m 10s
-
Define and use object variables3m 3s
-
(Locked)
Streamline code references using With…End With statements4m 40s
-
(Locked)
Challenge: Define variables, constants, and calculations2m 5s
-
(Locked)
Solution: Define variables, constants, and calculations3m 13s
-
(Locked)
-
-
-
-
-
-