VBA PLAYLIST: • Learn Excel VBA (Visual Basic for App...
Explore the Input Box, Message Box, and Active Cell in VBA during this second topic in the Visual Basic for Applications (VBA) for Microsoft Excel series. Follow along with Hassan in this hands-on session.
hello guys my name is Khan and in today's video we will cover a few different concepts mainly talking about input box message box in Excel media and also we'll be talking about while coding it will also put Adam sighs to eye towards active cell value active cell row and at the cell column so before going further suppose if I have selected this a1 cell so this is considered to be active cell in Excel or in VBA so for now just let's see to this C 2 is active cells so I can change where you treat the value within this cell that's why this is an active cell and if I say what's the active row of this cell with this which will be 2 and what will be the active column of this cell will be C or you can 3 because the 3 is the third column that I have selected so before going further what I will do I will because I will be creating a macro so first I will save I think it's a matter to make it a happy habitat whenever you start working on your excel especially when you were working on our VBA save it first in a so I will go to file save and then this is the folder that I will be using I will be naming as input box you can mean whatever you want and I will not be you saving it an Excel workbook because I will be using macros I will be creating a macro so I'll be saving it as Excel macro enabled workbook and I will save it so everything good now so I just what I will do I will select my a one and now this will be my active cell in order to create a macro you have to go to developer as I told you where before if you guys don't see this Developer tab in your exit I have already shown that how you can activate it so you can go developer and you can go to visual basic and here this is my sheet this is the extra good that I have created and here what I will do I will create my order create my macros so in order to create a macro you can see there is a down arrow button here I will click it and I will say add a module so module will allow me to create a macro so suppose if I want to name my macro so whenever you have to create a macro you have to start with sub and then suppose my sub name is roll number so suppose what I am doing is I will try to create an input box in which I will be asked they use it to add to write down your roll number so let's see if I say I'm just giving an arbitrary name roll number and sub is getting close by these parentheses enter so from the sub my macro starting an end sub is this line wave mind if macro will be ending in all the code that I will be writing for my macro we'll be doing these two line so the first thing that I would like to show suppose I want to create an input box which will pop up on the screen and ask the user to enter your roll number but whatever you will write the roll number I like to assign that to roll number to some objects cause if I want to create one dimension name roll number I think you can I am calling it a string because it will not give an error even the user add any alphabet and now what I will do I will add my roll number so I will be saying roll number is equal to input box
and here I will write down what I want to write down for the user so I will say please write down your roll number here
that's close let's see what it do so in order to execute it I will run it so here you can see because of the input box when I executed the macro this is the thing that I have written down in within the parentheses please write your roll number here and so suppose if I write down to 5 1 1 and say okay so what's happening is that this input is getting the value 2 5 4 4 and assigning it to this roll number object that I have created but suppose now I want to create a message box so massive box will be another pop-up which can give up which can we don't allow you to input a value but it will give you some message so in order to create that I will say message box and within Mexico I will sing the first part will be hella verb tense for include space and here and after that I would like to write the actual roll number which we have captured through this input box which is now assigned to this roll number object by sing underscore roll number and now let's see what I executed what happens
say six five four four okay and you can see it's saying thanks for entering six four four so this is the way you can play around wit