From the course: Excel: Learning VBA

Unlock the full course today

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

Solution: Define variables, constants, and calculations

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…

Contents