Introduction to VBA
VBA stands for Visual Basic Application..
It is an event driven Programming language by Microsoft now a days
it is predominantly used with Microsoft applications such as MS –Excel ,
MS-Word, MS-Access.
VBA Application
MS-Excel Provides loads on
inbuilt functions.MS-Excel Provides only basic inbuilt functions which may not
be sufficient to perform complex calculations but by using VBA we can create
our own functions and perform our desirable tasks
How to
Access VBA Editor
In excel windows Press “ALT +F11” to open VBA editor ..
Step 1: At first open Excel sheet
Step 2: Follow Above Tricks and open VBA Editor will be open which looks like this .
Some
Important VBA Terminologies
Modules :
Modules is the area
where code is written. In above figure there is no any modules.
How to
insert Module ???
To insert modules in VBA right
click on Microsoft Office Objects and then
a window open and on that window a insert option is available move to
cursor to that option and we obtain module at there then click on module option
and we obtain the Module.
Procedures :
Procedures are group of statements like methods in JAVA and
which instructs to VBA how to perform a specific task. Performed task may be
complicated or simple.
Procedures are classifieds in two ways .
Comments in VBA
- In VBA for writing comments we used ‘
Example :
Sub
excelPortExample()
‘this is my first code in ABA Program
End Sub
Then in this case VBA code compiler read it
as a comment line.
- · We can also write comments by using Rem
Example :
Sub excelPortExample()
REM This is my First VBA program
End Sub
Note : In this case also VBA code compiler treat REM
as a comment line.
MessageBox
:
MessageBox is a function life printf in C language and it is
also used to print message.
Syntax
MsgBox(prom
pt[,buttons][,title][,helpfile,context])
Hello World in VBA
Sub excelVbaPort()
MsgBox ("Hello VBAExcelPort")
End Sub
Sub excelVbaPort()
MsgBox ("Hello VBAExcelPort")
End Sub
Output :
great ....good keep it up
ReplyDeleteThank you sir we need ur proper guidance to make it more useful
DeleteThis comment has been removed by the author.
Delete