MS Excel Training For Business Managers/Working Professionals
MS Excel Training For Business Managers/Working Professionals
MS Excel Training For Business Managers/Working Professionals
Rajesh Math
Excel Introduction
History
Applications
Online Help
Excel Techniques
Named Ranges
VLOOKUP and HLOOKUP
Data validation
Excel Tips-Tricks
Little know Secrets of Excel
Menus Ribbon
Templates : Reusing Documents
Office Online Templates
Custom Templates
Pivot Table
Creating Pivot Table
Creating Pivot Charts
Data Table
Scenarios for what-if Analysis
Excel Formulas
Sorting and Filtering
Connecting Excel To Database
Connecting Excel to Web
Macros
Difference in Absolute and Relative Referencing
Concept of macro
Where macros can be stored
Assigning macros to key board short-cuts, buttons, icons (toolbars)
Introduction to VB Editor
Project Explorer
Creating Modules
Variables, Constants
Message Box, Input Box
VBA If and Loops
It allows users to input data into cells included in a grid made of rows and
columns. The user can introduce functions and, referring to the cells by its name
(formed by the letter or combinations of letters that identifies the column and the
number that identifies the row), can display the result in that cell. The result will
change dynamically if the content of the included cells changes.
Each file produced by Excel is called a book. Each book can contain several
sheets, with different names . Each cell can contain a different piece of
information, and can be referred by its unique name.
A spreadsheet is a table used to store various types of data. The data is arranged
in rows and columns to make it easier to store, organize, and analyze the
information. A spreadsheet application is a computer program such as Excel,
Lotus 1-2-3, OpenOffice Calc, or Google Spreadsheets. It has a number of built
in features and tools, such as functions, formulas, charts, and data analysis tools
that make it easier to work with large amounts of data.
When working with large workbooks in which all of the worksheet tabs are
not visible, you may get frustrated with scrolling to find the sheet you need.
Here's a really quick tip to pass on. Right-click on any of the tab-scrolling
buttons (to the left of the sheet tabs) and select the tab you want by clicking
on the name.
A Template is essentially a model that serves as the basis for more usage.
An Excel template is a workbook that’s used to create other workbooks.
A custom template is essentially a normal workbook, and it can use any Excel feature, such
as charts, formulas and macros. Usually, a template is set up so that the user can enter
values and get immediate results. In other words, most templates include everything but
the data, which is entered by the user.
Excel supports three types of templates, which I discuss in the following sections:
1. The default workbook template: Used as the basis for new workbooks.
2. The default worksheet template: Used as the basis for new worksheets inserted into a
workbook.
3. Custom workbook templates: Usually, these ready-to-run workbooks include formulas,
but they can be as simple or as complex as you like. Typically, these templates are set up
so that a user can simply plug in values and get immediate results. The Microsoft Office
Online templates are examples of this type of template.
An absolute reference uses two dollar signs in its address: one for the
column letter and one for the row number (for example, $A$5). Excel
also allows mixed references in which only one of the address parts is
absolute (for example, $A4 or A$4).
By default, Excel creates relative cell references in formulas. The
distinction becomes apparent when you copy a formula to another cell.
When you copy a formula, you have the choice of making it relative or absolute. Relative
references adjust to location. Absolute references remain constant regardless of location.
The commands available in the Ribbon vary, depending upon which tab is selected. The Ribbon is
arranged into groups of related commands. Here’s a quick overview of Excel’s tabs.
Home: You’ll probably spend most of your time with the Home tab selected. This tab contains the basic Clipboard
commands, formatting commands, style commands, commands to insert and delete rows or columns, plus an assortment
of worksheet editing commands
Insert: Select this tab when you need to insert something in a worksheet—a table, a diagram, a chart, a symbol, and so
on.
Page Layout: This tab contains commands that affect the overall appearance of your worksheet, including settings that
deal with printing.
Formulas: Use this tab to insert a formula, name a range, access the formula auditing tools, or control how Excel
performs calculations.
Data: Excel’s data-related commands are on this tab.
Review: This tab contains tools to check spelling, translate words, add comments, or protect sheets.
View: The View tab contains commands that control various aspects of how a sheet is viewed.Some commands on this
tab are also available in the status bar.
Developer: This tab isn’t visible by default. It contains commands that are useful for programmers. To display the
Developer tab, choose Office ➪ Excel Options and then select Popular. Place a check mark next to Show Developer Tab
In The Ribbon.
Add-Ins: This tab is visible only if you’ve loaded a workbook or add-in that customizes the menu or toolbars. Because
menus and toolbars are no longer available in Excel 2007, these customizations appear in the Add-Ins tab.
Types of Names :
Defined name A name that represents a cell, range of cells, formula, or constant value.
Table name A name for an Excel table, which is a collection of data about a particular subject that is stored in records
(rows) and fields (columns).
The V in VLOOKUP stands for vertical. Use VLOOKUP instead of HLOOKUP when your comparison
values are located in a column to the left of the data that you want to find.
Syntax
VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
Lookup_value The value to search in the first column of the table array (array: Used to build single formulas
that produce multiple results or that operate on a group of arguments that are arranged in rows and columns.
An array range shares a common formula; an array constant is a group of constants used as an argument.).
Lookup_value can be a value or a reference. If lookup_value is smaller than the smallest value in the first
column of table_array, VLOOKUP returns the #N/A error value.
Table_array Two or more columns of data. Use a reference to a range or a range name. The values in the
first column of table_array are the values searched by lookup_value. These values can be text, numbers, or
logical values. Uppercase and lowercase text are equivalent.
Col_index_num The column number in table_array from which the matching value must be returned. A
col_index_num of 1 returns the value in the first column in table_array; a col_index_num of 2 returns the
value in the second column in table_array, and so on. If col_index_num is:
Less than 1, VLOOKUP returns the #VALUE! error value.
Greater than the number of columns in table_array, VLOOKUP returns the #REF! error value.
*** http://www.experiglot.com/2007/12/27/how-to-use-vlookup-in-excel-part-ii-
some-tips-and-advanced-excel-tricks/
Microsoft Excel data validation lets you define what type of data you
want entered in a cell. For example, you can allow entry of a letter grade
with only the letters A through F. You can set up data validation to
prevent users from entering data that isn't valid, or allow invalid data
but check for it after the user is finished. You can also provide messages
to define what input you expect for the cell, and instructions to help users
correct any errors.
Data validation is particularly useful when you're designing forms or
worksheets that other people will use to enter data, such as budget forms
or expense reports.
The first step in creating a Pivot Table is to organize your data in a list of rows
and columns. In Excel 2007, you can format this list as an Excel Table, and use
that as the dynamic source for your Pivot Table.
Before you create a pivot table, make sure your data is organized correctly. There
are instructions on the following pages, for setting up your source data in a table,
organized into rows and columns.
An empty pivot table is created in your workbook, either on a new sheet, or the
existing sheet that you selected. When you select a cell within the pivot table, a
PivotTable Field List appears, at the right of the worksheet.
In a Pivot Table, you can group the items in a Row or Column field.
For example, items in a date field can be grouped by month, and items in
a number field can be grouped by tens.
In the Sample Pivot Sales book -> TestPivot sheet
Right-click the Date field button.
Choose Group to select the Group Field
Open Ex06PivotSales.xlsx
Let us review Ex06PivotTableExpensesByWeekCategory.xls
Verify the results using Sort & Filter(which is covered later)
In Excel, a Data Table is a way to see different results by altering an input cell in your
formula. Data Tables is also an advanced topic in Microsoft Excel that falls under the
category of What-If Analysis. What-If or Sensitivity Analysis is carried out to study the
variation of the output to changes in the input variable.
Consider a case of compound interest, where you invest a certain amount of money in a
bank deposit and the amount is compounded every year.
Formula for calculating compound interest:
A = P * (1 + r/n) ^ nt
Where:
P = principal amount (initial investment)
r = annual interest rate (as a decimal)
n = number of times the interest is compounded per year
t = number of years
A = amount after time t
Now, if suppose we want to see what the final amount will be at different interests rates,
we can quickly use a data table for the same.
Open a new excel file and enter the following given screenshot below:
The cell B5 has the formula =B1 * (1 + B2) ^ B3
As you can see, the $5000 invested at 7.5% for 5 years will give 7,178.15.
Now, we will create a data table to see what amount we will receive by changing
the interest rate.
Fill cells A6 to A10 with different interest rates. I've filled it with values from 6% to
10%. Now, select the cells A5:B10.
In Excel 2007, goto Data > What-If Analysis > Data Table. In Excel
2003, the menu path is Data > Table or you can use the shortcut key
Alt + D + T in this order.
Open Ex05zDataTable.xlsx
Formulas are one of the most useful and well used features in
spreadsheets such as Excel. Formulas can be used to perform basic
number crunching, such as addition or subtraction, as well as more
complex calculations such as payroll deductions or averaging a student's
test results. Using formulas effectively is central to getting the most out
of your spreadsheets.
ADDITION cell A1 to A10 = sum (A1: A10)
AVERAGE cell A1 to A10 = average (A1: A10)
MAXIMUM cell A1 to A10 = max (A1: A10)
MINIMUM cell A1 to A10 = min (A1: A10)
IF(A1 <= 0; "ordering", "stock")
This would mean: If the contents of cell A1 is less than or equal to zero, then it displays "to
order", otherwise (if the contents of cell A1 is greater than zero) on display "at stock".
Sort and Filter Sorting and Filtering allow you to manipulate data in a
worksheet based on given set of criteria.
Basic Sorts To execute a basic descending or ascending sort based on
one column:
1. Highlight the cells that will be sorted
2. Click the Sort & Filter button on the Home tab
3. Click the Sort Ascending (A-Z) button or Sort Descending (Z-A)
button
Filtering allows you to display only data that meets certain criteria. To filter:
Click the column or columns that contain the data you wish to filter
On the Home tab, click on Sort & Filter
Click Filter button
Click the Arrow at the bottom of the first cell
Click the Text Filter
Click the Words you wish to Filter
It allows users to input data into cells included in a grid made of rows
and columns. The user can introduce functions and, referring to the cells
by its name (formed by the letter or combinations of letters that identifies
the column and the number that identifies the row), can display the result
in that cell. The result will change dynamically if the content of the
included cells changes.
If you perform a task repeatedly in Microsoft Excel, you can automate the
task with a macro. A macro is a series of commands and functions (function:
A prewritten formula that takes a value or values, performs an operation,
and returns a value or values. Use functions to simplify and shorten formulas
on a worksheet, especially those that perform lengthy or complex
calculations).
When you find yourself repeatedly performing the same actions or tasks
in a spreadsheet, it might be time for you to create a macro.
Complex macros are usually created in Excel with the Macro editor.
Simpler macros can, however, be created using the Excel macro
recorder.
VBA newcomers are often overwhelmed by the terminology that is used in VBA. I’ve put together some key
definitions to help you keep the terms straight. These terms cover VBA and UserForms two important elements
that are used to customize Excel.
1. Code: VBA instructions that are produced in a module sheet when you record a macro. You also can enter VBA
code manually.
2. Controls: Objects on a UserForm (or in a worksheet) that you manipulate. Examples include buttons, check
boxes, and list boxes.
3. Function: One of two types of VBA macros that you can create. (The other is a Sub procedure.) A function
returns a single value. You can use VBA functions in other VBA macros or in your worksheets.
4. Macro: A set of VBA instructions performed automatically.
5. Method: An action taken on an object. For example, applying the Clear method to a Range object erases the
contents and formatting of the cells.
6. Module: A container for VBA code.
7. Object: An element that you manipulate with VBA. Examples include ranges, charts, drawing objects, and so on.
8. Procedure: Another name for a macro. A VBA procedure can be a Sub procedure or a Function procedure.
9. Property: A particular aspect of an object. For example, a Range object has properties, such as Height, Style, and
Name.
10. Sub procedure: One of two types of Visual Basic macros that you can create. The other is a function.
11. UserForm: A container that holds controls for a custom dialog box and holds VBA code to manipulate the
controls.
12. VBA: Visual Basic for Applications. The macro language that is available in Excel, as well as in the other
applications in Microsoft Office.
13. VB Editor: The window (separate from Excel) that you use to create VBA macros and UserForms.
You will develop, test and modify VBA procedures (macros) in the Excel Visual Basic
Editor (VBE). It is a very user friendly development environment. The VBA procedures
developed in the Excel Visual Basic Editor become part of the workbook in which they are
developed and when the workbook is saved the VBA components (macros, modules, user
forms. etc.) are saved at the same time. When you send the workbook to the "Recycling bin"
the VBA procedures are gone.
The immediate window is used when you are developing your macro code
If you store one or more macros in a workbook, the file must be saved with macros
enabled, which is a file with an XLSM extension.
A VBA macro (also known as a procedure) can be one of two types:
1. Sub : It is a new command that either the user or another macro can execute.
2. Function : A function always returns a single value (just as a worksheet function
always returns a single value).
A VBA module, which is displayed in a separate window, works like a text editor. You can
move through the sheet, select text, insert, copy, cut, paste, and so on.
You perform actions in VBA by writing (or recording) code in a VBA module sheet and
then executing the macro in any one of various ways. VBA modules are stored in an Excel
workbook, and a workbook can hold any number of VBA modules.
When you enter code in a module sheet, you’re free to use indenting and blank lines to
make the code more readable. (In fact, this is an excellent habit.)
After you enter a line of code (by pressing Enter), it’s evaluated for syntax errors. If none
are found, the line of code is reformatted, and colors are added to keywords and identifiers.
Most user-created macros are designed for use in a specific workbook, but you may want
to use some macros in all your work. You can store these general-purpose macros in the
Personal Macro Workbook so that they’re always available to you. The Personal Macro
Workbook is loaded whenever you start Excel.
The Dim (stands for dimension) statement is used to declare variables and allocate storage space. It may
appear in a General Declarations section at the top of a code module -or- immediately following a
procedure declaration.
For example ...
Sub SampleCode()
Dim MyNumber as Integer
' Other program statements go here
End Sub
Variables declared within a procedure are not available to other procedures and they only retain values
for the life of that procedure. This refers to a variable's scope. Variables declared at a module-level (or
within a form's General Declarations section) are available to all procedures within that module or form
-and- they continue to retain assigned values for the life of the program. However, these variables are
not available to procedures outside of the module in which they are declared. One alternative to the Dim
statement is the Public keyword, which expands the scope of the variable to make it available to other
procedures outside it's own module or form. It's a better practice to use the narrowest possible scope for
your variables.
Note: Other approaches to scope involve Global, Private, and Static declaration. Also, very similar to
variables are Constants.
Msgbox : Displays a message in a dialog box, waits for the user to click a
button, and returns an Integer indicating which button the user clicked.
Syntax
MsgBox(prompt[, buttons] [, title] [, helpfile, context])
Displays a prompt in a dialog box, waits for the user to input text or click
a button, and returns a String containing the contents of the text box.
Syntax
InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context])
Loops
1. Do Loop : Suppose you wanted to count the number of rows in a
range of data that can sometimes be small and sometimes really big.
You'd want to use a Do…Loop. This type of loop performs an
action as many times as necessary. It would count whatever number
of rows it found in the range.
Here the While condition is used so that the loop runs as long as the
cell being acted on is not blank. The row being worked on is x, and
(x,1) is the first cell in that row. Used together, the signs <> mean
"does not equal." The quotation marks with nothing between them
indicate a blank cell.
If you wanted the loo
Loops
2. The For Each…Next Loop : You would use the For Each…Next
loop to perform an action on every cell in a range of data. Suppose,
for example, that you wanted to make the word "OK" darker than
other text everywhere in a selected range .
"MyCell" means whatever cell the loop is working on, and "For Each"
means that the loop will work on all cells in the selection. If the loop
finds a cell containing only the word "OK", then it makes that word
darker.
Loops
3. The Do…Loop and the For Each…Next loop are powerful in
simple ways. Now we're going to ratchet up the complexity a bit by
introducing nested loops. You use nested loops when you need to
perform an action on a range of data more than once, or through
more than one range of data. For an analogy to nested loops, think
of the Earth revolving around the Sun. One full revolution around
the Sun, a year, is like the outside loop, and one rotation of the
Earth around its axis, a day, is like the inside loop nested within the
outside loop. For each year, there are 365 inside loops, and on
every January 1st, the outside loop repeats.