Assignment on Visual Basics in Excel
Assignment on Visual Basics in Excel
Sem: 6
List of Contents
● Introducing VBA
● Getting Started With VBA
● Some Basic Functions
● Creating a Button
● Creating a Message Box
● Learning About Macros
● References
Introduction
Visual Basic for Applications is a powerful tool that unlocks a whole new level of automation
and customization within your spreadsheets. Think of it as giving Excel its own programming
language, allowing you to go beyond the standard formulas and built-in features.
● Creating Custom Functions: While Excel has a vast library of built-in functions,
sometimes you need something specific to your work. VBA allows you to create your
own user-defined functions (UDFs) that you can then use in your formulas just like
any standard Excel function.
● Developing User Forms: Need a custom dialog box to gather input from users, or a
more interactive way to present data? VBA enables you to design and implement
user forms with various controls like buttons, text boxes, and dropdown lists.
● Manipulating Data: VBA provides fine-grained control over your data. You can write
code to filter, sort, validate, import, export, and transform data in ways that standard
Excel features might not easily allow.
● Interacting with Other Applications: VBA isn't limited to just Excel. It can also interact
with other Microsoft Office applications like Word and Outlook, as well as other
applications that expose an object model. This opens doors for creating integrated
workflows.
● Customizing the Excel Environment:You can use VBA to modify the Excel interface
itself, such as adding custom ribbon tabs, creating custom menus, or responding to
specific Excel events (like opening a workbook or changing a cell value).
● Generating Reports and Charts: Automating the creation of complex reports and
charts based on your data becomes much easier with VBA. You can dynamically
update these visuals as your data changes.
2.Enhanced Functionality: VBA extends the capabilities of Excel far beyond its
built-in features, allowing you to create tailored solutions for your specific needs.
3.Customization and Flexibility: You have complete control over how Excel
behaves and interacts with your data. This level of customization isn't possible with
standard Excel features alone.
6.Code Reusability: Once you've written a VBA macro or function, you can often
reuse it in other workbooks or adapt it for similar tasks, saving development time in
the long run.
7.Better User Experience: Custom user forms and interactive elements can make
your Excel-based tools more user-friendly and intuitive.
In essence, VBA transforms Excel from a powerful spreadsheet application into a versatile
platform for building custom business solutions. It's a valuable skill for anyone who works
extensively with data and wants to take their Excel proficiency to the next level.
● In the right-hand pane, under Main Tabs, check the Developer box.
● Click OK.
● With the Developer tab now visible, click the Visual Basic button in the Code group .
● Alternatively, press the keyboard shortcut Alt+F11.
Step 3. Click the Insert tab. Choose Module. The Coding window opens where you can
perform so many things and automate the Excel.
Step 4.Whatever actions you want to perform, you can do so by giving instructions in the
coding window.
● For e.g. here we want that our word should become bold, italic and underlined with
one action, so we create a function BUI.
● When you click on play the function gives us the desired outcome.
Step 5. Type the word 'Hey There' in the Excel sheet.
Now to make it bold, italic and underlined, we use the function BUI rather than conventional
way.
Step 6. Select the cell in which you want to perform the action.
Step 7. We can also create a specific button for the function BUI in the Excel sheet as well.
● For this click on the Insert tab and click on the button icon.
● Then select the location where you want the button.
Step 8. A button titled BUI appears in the Excel sheet.
We can configure the message box to provide the user with a number of different buttons
such as Yes, No, Ok, Retry, Abort, Ignore and Cancel. The MsgBox function will then return
the button that was clicked.
● For example, we can create a message box that tells the user the time.
● VBA helps us create such boxes, which make the usage of excel more interactive.
● The MsgBox function displays a message box and waits for the user to click a button
and then an action is performed based on the button clicked by the user.
When the user clicks the Yes button, time appears on the screen.
Like this MsgBox function can be used to even warn the user, also it can provide information
like time, date, etc.
The MsgBox function can return one of the following values which can be used to identify the
button the user has clicked in the message box.
1) Before you record a macro Macros and VBA tools can be found on the Developer tab,
which is hidden by default and you can access them by pressing ALT+F11.
2) In the Code group on the Developer tab, click Record Macro. Optionally, enter a name for
the macro in the Macro name box, enter a shortcut key in the Shortcut key box, and a
description in the Description box, and then click OK to start recording
.
When a data is given to you, and it is very raw, unfiltered data, then you have to perform
multiple functions in Excel to make this data representable.
When you do this on a daily basis, it becomes a hectic job. Macros can help us save time
and effort by performing multiple actions simultaneously.
All that we need to do is to record the set of actions in the form of macro.
Step 1. Click on the Developer tab and then click on Record Macro bar.
Step2. Name the macro and then store the macro in This Workbook.
https://learn.microsoft.com/en-us/office/vba/library -reference/concepts/getting-started-with-
vba-in-office
2. Applications of VBA
tps://corporatefinanceinstitute.com/resources/excel/excel-vba/
https://support.microsoft.com/en-us/office/run-a-macro-in-excel-5e855fd2-02d1-45f5-90a3-
50e645fe3155
https://youtu.be/G05TrNZnt6k?si=3njF5t1Ivize5nEj