Excel VBA - Variable Usage

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we learn about the topic named as variables variables are basically names of your memory in your location which will hold certain values when I say certain values it can be anything takes numbers or you have date and time it can be object so basically variable will hold some values into that and that is nothing but the name of your memory location so let us see that I'll tell you why memory why we need the variables into our application what is the use of it so first thing is I'll just show you the file which I've created that is excel vba building codes the name of the sheet is sheet 1 okay so I'll go to this developer tab and click on this Visual Basic I can explain you the usage of variable with the help of macro okay so in this place what I've done is I have created a module named as variable usage now in that module I have written a macro so if you see sub procedure variable usage and I have written something at the bottom emphasis it's very simple code that is range a one dot value equal to totals range a full dot value equal to totals range a night dot value equal to totals so everywhere if you see the two totals what is repeated every now and then so imagine if I want to write the same thing in multiple cells I have to keep on writing it multiple times why not store that value the value have stored this two tools into this variable there is nothing but a variable there is the name of your memory location which will hold certain value now the value is nothing but text now what I've done is have copy pasted here same value of copy pasted except I've changed this numbers C 1 C 5 C 7 C 9 and inside that instead of this tootles what I've done is I've added this variable 1 okay if you see variable one variable one where one Belvin everywhere now what does this valve and consists of it consists of this text tutors right now if I execute both will do the same task but for me to write this one is very easy as compared to writing this text so if you see if I execute this part if I keep my cursor if I click on is step into step into again and if I click on step into a one cell should contain now as tutors if you see here again if I click on step into a four should contain two tools again if I click on step into and if you see the value will keep on getting added it will do the same task again if I click on step into step into right now if you see now see one value that is armen okay if I just shift here see one should contain the value a square one that is two tools same it is working right if I keep on clicking other places so I'll get the same value now which one is easy you can tell me now if I want to change instead of two tools if I want to write as point so I have to change everywhere in all the places so if I go to this place okay if I just move the screen so you can see that here if I want I can write as P here if I want I can just write at P okay so you can see how much effort I have to take on keep on writing in this place there sir these are just four statements imagine four four statements I have tried four times if there are 40 statements it will take longer time but here instead of writing at the four places I can just change here instead of two totals point I have write as Tootles and I'll write as P itself so the value in this variable has changed so all these places now the variable or variable one value will be changed so this one is very much easy for changing part right at any point of time you can just change at one place and all the places it will be changed whereas at this place every place you have to go and change everything right now if you execute it will show you the same answer now if you want to run at one place you can just click on this Run button and everything will be executed at one time right I'll just keep my cursor click on this run okay so if you see here at the back end everywhere you can see two turns P Tootles P and Turtles be everywhere you can get it right so changing this one where the variable was used was easy as compared to the fixed value these are rigid values these are flexible values that's a variable you use used flexible values right so I'll just lose it right so I hope you have understood what is a variable and what is the usage of variable it is helpful to reduce your task effort and money also that's all for this video
Info
Channel: Tutorials Point (India) Ltd.
Views: 87,865
Rating: 4.8722043 out of 5
Keywords: Excel VBA - Variable Usage, VBA, Marcos, Microsoft, Excel VBA
Id: DpOoE4U4iGg
Channel Id: undefined
Length: 3min 53sec (233 seconds)
Published: Tue Dec 06 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.