0% found this document useful (0 votes)
20 views65 pages

NEW IT SKILL-2 File

Uploaded by

Ayush Shukla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views65 pages

NEW IT SKILL-2 File

Uploaded by

Ayush Shukla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

lOMoAR cPSD| 24516743

INDEX
PAGE
S.NO PARTICULAR NO.

1 HOW TO CREATE A PIVOT TABLE 3-8


HOW TO ANALYZING DATA USING GOAL SEEK
2 & SOLVER IN PIVOT TABLE 9-10
HOW TO CREATE A SUMMERY REPORT IN
3 PIVOT TABLE 11-13
HOW TO VALIDATE AND AUDIT DATA IN PIVOT
4 TABLE 14-23
HOW TO SET, EDIT VALIDATE CRITERIA FOR
DATA ENTRY IN A CELL RANGE LIKE: WHOLE
5 NUMBER, DECIMAL, DATE, TIME 24- 27
HOW TO CREATE APPLICATION IN
6 SPREADSHEET AND MACROS 28- 41

7 HOW TO CREATE A COLUMN CHART 42-43

8 HOW TO CREATE A BAR CHART 44-50

9 HOW TO CREATE A LINE CHART 51-54

10 HOW TO CREATE A PIE CHART 55-57


HOW TO CREATE A COMBINED CHART LIKE:
11 COLUMN AND LINE, COLUMN AND AREA 58-63

12 HOW TO DISPLAY AN IMAGE IN CHART AREA 64-66

2
lOMoAR cPSD| 24516743

HOW TO CREATE A PIVOT TABLE

Pivot tables are one of Excel's most powerful features. A pivot table allows you to extract
the significance from a large, detailed data set.
Our data set consists of 213 records and 6 fields. Order ID, Product, Category, Amount,
Date and Country.

Insert a Pivot Table


To insert a pivot table, execute the following steps.
1. Click any single cell inside the data set.

2. On the Insert tab, in the Tables group, click PivotTable.

The following dialog box appears. Excel automatically selects the data for you. The default
location for a new pivot table is New Worksheet.

3. Click OK.

3
lOMoAR cPSD| 24516743

Drag fields
The PivotTable Fields pane appears. To get the total amount exported of each product,
drag the following fields to the different areas.
1. Product field to the Rows area.

2. Amount field to the Values area.

3. Country field to the Filters area.

Below you can find the pivot table. Bananas are our main export product. That's how easy
pivot tables can be!

4
lOMoAR cPSD| 24516743

Sort
To get Banana at the top of the list, sort the pivot table.

1. Click any cell inside the Sum of Amount column.

2. Right click and click on Sort, Sort Largest to Smallest.

Result.

5
lOMoAR cPSD| 24516743

Filter
Because we added the Country field to the Filters area, we can filter this pivot table by
Country. For example, which products do we export the most to France?

1. Click the filter drop-down and select France.

Result. Apples are our main export product to France.

Note: you can use the standard filter (triangle next to Row Labels) to only show the
amounts of specific products.
Change Summary Calculation
By default, Excel summarizes your data by either summing or counting the items. To
change the type of calculation that you want to use, execute the following steps.

1. Click any cell inside the Sum of Amount column.

2. Right click and click on Value Field Settings.

3. Choose the type of calculation you want to use. For example, click Count.

6
lOMoAR cPSD| 24516743

4. Click OK.

Result. 16 out of the 28 orders to France were 'Apple' orders.

Two-dimensional Pivot Table


If you drag a field to the Rows area and Columns area, you can create a two-dimensional
pivot table. First, insert a pivot table. Next, to get the total amount exported to each
country, of each product, drag the following fields to the different areas.
1. Country field to the Rows area.

2. Product field to the Columns area.

3. Amount field to the Values area.

4. Category field to the Filters area.

7
lOMoAR cPSD| 24516743

Below you can find the two-dimensional pivot table.

To easily compare these numbers, create a pivot chart and apply a filter. Maybe this is one
step too far for you at this stage, but it shows you one of the many other powerful pivot
table features Excel has to offer.

8
lOMoAR cPSD| 24516743

HOW TO ANALYZING DATA USING GOAL SEEK AND


SOLVER IN PIVOT TABLE

The Goal Seek Excel function (often referred to as What-if-Analysis) is a method of solving
for a desired output by changing an assumption that drives it. The function essentially
uses a trial and error approach to back-solving the problem by plugging in guesses until it
arrives at the answer.

For example, if the formula for revenue is equal to the number of units sold multiplied by
the selling price, Goal Seek can determine how many units have to be sold to reach $1
million of revenue, if the selling price is known. The function is extremely useful
for performing sensitivity analysis in financial modeling.

Simple Goal Seek Example

Let’s look at a simple exercise first, to see how Goal Seek works. Suppose we have a very
basic model that takes the number of units sold, the retail price, and a discount to
calculate total net revenue.

The current model contains the following information:

 # of units: 500
 Retail price: $25.00
 Selling discount: 10%
 Revenue: $11,250

Now suppose we want to find out how many units have to be sold to reach $20,000 of
revenue. See the screenshot below and follow the steps listed to use the Goal Seek Excel
tool.

9
lOMoAR cPSD| 24516743

Steps to Use Goal Seek Excel:

1. Put the cursor on the cell that contains the output you want to change (revenue)
2. On the Data ribbon, select What-if-analysis, then select Goal Seek (keyboard
shortcut is Alt, A, W, G)
3. When the dialog box appears (as shown below) make “Set cell” equal to the
revenue cell (E10)
4. Set “To value” equal to the output you want to achieve (type the number in)
5. Set “By changing cell” equal to the assumption you want to solve for (# of units, or
cell E4)
6. Press OK

Below is the output from the analysis. We can see that to achieve $20,000 of revenue,
889 units need to be sold. Notice that the solution is displayed directly in cell (E4), not in
the dialogue box.

Press OK to keep the solution running in the model (cell E4 will permanently change to
889 units), or press Cancel to return to the original assumption (500 units).

10
lOMoAR cPSD| 24516743

HOW TO CREATE A SUMMARY REPORT IN PIVOT TABLE

Microsoft says that 80% of people using Excel have never used a pivot table. As I near the
end of my series of 40 Days of Excel, an introduction to pivot tables.

Pivot tables are miraculous. You are given a workbook with thousands of rows of detailed
data. You can summarize that data in just a few clicks using a pivot table. I've written
entire books on pivot tables, so today, I want to walk you through building your first pivot
table.

Say that you have 6464 rows of data with Customer, Product, Date, Quantity Revenue. You
want to find the revenue for the top 5 customers who bought widgets.

1. Select one cell in your data set


2. On the Insert tab of the Ribbon, select Pivot Table

Start your pivot table

3. In the Create PivotTable dialog, choose Existing Worksheet. Always leave a blank
column between your data and the pivot table, so in this case, choose cell G2 for
the place to hold your pivot table.

11
lOMoAR cPSD| 24516743

Select where to build the pivot table

The PivotTable Fields panel appears on the right side of your screen. At the top of
the panel are a list of the fields in your data set. At the bottom are four drop zones
with confusing names.

Drag fields to these drop zones

4. Drag the Customer field from the top of the PivotTable Fields list and drop it in the
Rows drop zone.
5. Drag the Revenue field from the top of the PivotTable Fields list and drop it in the
Values drop zone.
6. Drag the Product field to the Filters drop zone.
7. Open the filter drop-down in H2 and choose Widget. At this point, you will see a
summary of the customers who bought widgets/

12
lOMoAR cPSD| 24516743

Just 7 steps to build this summary report

8. There are two PivotTable tabs in the Ribbon. Go to the Design tab. Choose Report
Layout, Show in Tabular Form. This changes the heading in G3 from Row Labels to
Customer. It also makes the pivot table better if you add more row fields later.
9. Open the drop-down in G3. Choose Value Filters, Top Ten. In the Top 10 Filter
(Customer) dialog, choose Top, 5 Items by Sum of Revenue. Click OK.
10. Pivot tables never choose the right number format. Select all of the Revenue cells,
from H4:H9. Assign a Currency format with 2 decimal places.
11. If you want the report sorted with the largest customer at the top, choose any one
revenue cell and click the Sort Descending (ZA) icon on the Data tab. This is a
shortcut for opening the drop-down in G3 and selecting Sort Z to A.

At this point, you've solved the original question:

The finished pivot table


However, Pivot Tables are easy to change. Now that you've answered the first question, try
any of these:

 Change the dropdown in H1 from Widget to Gadget to see the top customers for
gadgets.
 Double-click the revenue in H4 to see a list of all the records that make up that
data. The report appears on a new worksheet to the left of the current worksheet.
 Click the Pivot Chart icon on the Analyze tab to chart the top 5 customers

13
lOMoAR cPSD| 24516743

HOW TO VALIDATING AND AUDITING DATA IN PIVOT


TABLE

You might want to check formulas for accuracy or find the source of an error. Excel Formula
Auditing commands provide you an easy way to find

 Which cells are contributing in the calculation of a formula in the active cell.
 Which formulas are referring to the active cell.
These findings are shown graphically by arrow lines that makes the visualization easy. You
can display all the formulas in the active worksheet with a single command. If your formulas
refer to cells in a different workbook, open that workbook also. Excel cannot go to a cell in
a workbook that is not open.

Setting the Display Options

You need to check whether the display options for the workbooks you are using are correctly
set.

 Click FILE > Options.


 In the Excel Options dialog box, click Advanced.
 In Display options for the workbook −
o Select the workbook.
o Check that under For objects, show, All is selected.
 Repeat this step for all the workbooks you are auditing.

Tracing Precedents

Precedent cells are those cells that are referred to by a formula in the active cell.
In the following example, the active cell is C2. In C2, you have the formula =B2*C4.
B2 and C4 are precedent cells for C2.

14
lOMoAR cPSD| 24516743

To trace the precedents of the cell C2,

 Click in the cell C2.


 Click the Formulas tab.
 Click Trace Precedents in the Formula Auditing group.

Two arrows, one from B2 to C2 and another from C4 to C2 will be displayed, tracing the
precedents.

Note that for tracing precedents of a cell, the cell should have a formula with valid references.
Otherwise, you will get an error message.

 Click in a cell that does not contain a formula or click in an empty cell.
 Click Trace Precedents in the Formula Auditing group.
You will get a message.

15
lOMoAR cPSD| 24516743

Removing Arrows
Click Remove Arrows in the Formula Auditing group.

All the arrows in the worksheet will disappear.

Tracing Dependents

Dependent cells contain formulas that refer to other cells. That means, if the active cell
contributes to a formula in another cell, the other cell is a dependent cell on the active cell.
In the example below, C2 has the formula =B2*C4. Therefore, C2 is a dependent cell on the
cells B2 and C4

To trace the dependents of the cell B2,

 Click in the cell B2.


 Click the Formulas tab.
 Click Trace Dependents in the Formula Auditing group.

16
lOMoAR cPSD| 24516743

An arrow appears from B2 to C2, showing C2 is dependent on B2.


To trace the dependents of the cell C4 −

 Click in the cell C4.


 Click the Formula tab > Trace Dependents in the Formula Auditing group.
Another arrow appears from C4 to C2, showing C2 is dependent on C4 also.

Click Remove Arrows in the Formula Auditing group. All the arrows in the worksheet will
disappear.
Note − For tracing dependents of a cell, the cell should be referenced by a formula in another
cell. Otherwise, you will get an error message.

 Click in the cell B6 is not referenced by any formula or click in any empty cell.
 Click Trace Dependents in the Formula Auditing group. You will get a
message.

17
lOMoAR cPSD| 24516743

Working with Formulae


You have understood the concept of Precedents and Dependents. Now, consider a
worksheet with several formulae.

 Click in a cell under Pass Category in Exam Results table.


 Click Trace Precedents. The cell to its left (Marks) and the range E4:F8 will be
mapped as the precedents.
 Repeat for all the cells under Pass Category in Exam Results table.

 Click in a cell under Pass Category in Student Grades table.


 Click Trace Dependents. All the cells under Pass Category in Exam Results table
will be mapped as the dependents.

Showing Formulas

18
lOMoAR cPSD| 24516743

The worksheet below contains the summary of sales by the salespersons in the regions East,
North, South, and West.

 Click the FORMULAS tab on the Ribbon.


 Click Show Formulas in the Formula Auditing group. The Formulas in the
worksheet will appear, so that you will know which cells contain formulas and
what the formulas are.

 Click in a cell under TotalSales.


 Click Trace Precedents. A worksheet icon appears at the end of the arrow. The
worksheet icon indicates that the precedents are in a different worksheet.

Double-click on the arrow. A Go TO dialog box appears, showing the precedents.

19
lOMoAR cPSD| 24516743

As you observe, there are four precedents, on four different worksheets.

 Click a reference of one of the precedents.


 The reference appears in the Reference box.
 Click OK. The worksheet containing that precedent appears.

Evaluating a Formula

To find how a complex formula in a cell works step by step, you can use Evaluate Formula
command.
Consider the formula NPV (Middle Year) in the cell C14. The formula is
=SQRT (1 + C2)*C10

 Click in the cell C14.


 Click the FORMULAS tab on the Ribbon.
 Click Evaluate Formula in the Formula Auditing group. The Evaluate Formula
dialog box appears.

In the Evaluate Formula dialog box, the formula is displayed in the box under Evaluation. By
clicking the Evaluate button several times, the formula gets evaluated step-wise. The
expression with an underline will always be executed next.

Here, C2 is underlined in the formula. So, it is evaluated in the next step. Click Evaluate.

20
lOMoAR cPSD| 24516743

Cell C2 has value 0.2. Hence, C2 will be evaluated as 0.2. 1+0.2 is underlined showing it
as the next step. Click Evaluate.

1+0.2 will be evaluated as 1.2. SQRT(1.2) is underlined showing it as next step.


Click Evaluate.

SQRT(1.2) will be evaluated as 1.09544511501033. C10 is underlined showing it as next


step. Click Evaluate.

21
lOMoAR cPSD| 24516743

C10 will be evaluated as 4976.8518518515.


1.09544511501033*4976.8518518515 is underlined showing it as next step.
Click Evaluate.

1.09544511501033*4976.8518518515 will be evaluated as 5,451.87.


There are no more expressions to evaluate and this is the answer. The Evaluate button will
be changed to Restart button, indicating completion of evaluation.

Error Checking

It is a good practice to do an error check once your worksheet and/or workbook is ready
with calculations.
Consider the following simple calculations.

The calculation in the cell has resulted in the error #DIV/0!.


 Click in the cell C5.
 Click the FORMULAS tab on the Ribbon.
 Click the arrow next to Error Checking in the Formula Auditing group. In the
drop-down list, you will find that Circular References is deactivated, indicating
that your worksheet has no circular references.
 Select Trace Error from the drop-down list.

22
lOMoAR cPSD| 24516743

The cells needed to compute the active cell are indicated by blue arrows.

 Click Remove Arrows.


 Click the arrow next to Error Checking.
 Select Error Checking from the drop-down list.

The Error Checking dialog box appears.

Observe the following −


 If you click Help on this error, Excel help on the error will be displayed.
 If you click Show Calculation Steps, Evaluate Formula dialog box appears.
 If you click Ignore Error, the Error Checking dialog box closes and if you
click Error Checking command again, it ignores this error.
 If you click Edit in Formula Bar, you will be taken to the formula in the formula
bar, so that you can edit the formula in the cell.

23
lOMoAR cPSD| 24516743

HOW TO SET, EDIT VALIDATION CRITERIA FOR DATA


ENTRY IN A CELL RANGE LIKE: WHOLE NUMBER,
DECIMAL, DATA, TIME

Create a Validation Rule


1. Select the cells you want to validate.

2. Click the Data tab.

3. Click the Data Validation button.

4. Click the Allow list arrow.


5. Select the type of data you want to allow.

o Any value: No validation criteria applied.


o Whole number: Allows a whole number between the minimum
and maximum limits set.
o Decimal: Allows a decimal or a percent entered as a decimal
between the set limits.
o List: Allows a value from a list of choices. A list arrow appears
in the cell, and users can choose from the list.
o Date: Allows a date within set limits.
o Time: Allows a time within set limits.

24
lOMoAR cPSD| 24516743

o Text length: Allows text containing a certain number of


characters.
o Custom: Allows a formula to be entered to calculate what is
allowed in the cell.

6. Specify the data validation rules.

The validation options will vary depending on the option selected in the
Allow field.

7. Click OK.

The data validation is set for the selected cell(s). When a user tries to enter
data that is not valid, Excel will prevent the entry and display a message
about the cell being restricted.

25
lOMoAR cPSD| 24516743

To find validated data in a worksheet, click the Find & Select button in the
Editing group on the Home tab and select Data Validation. The validated
cells are highlighted.
Add Input and Error Messages
Prevent data validation issues by setting up Excel to display a message whenever a cell or
range of cells is selected. These messages are useful when other people will be entering
data in your worksheet. An error message can be configured to appear when data is
entered that does not match a data validation rule.

1. Select the cells where you want an input message to appear.

2. Click the Data tab.


3. Click the Data Validation button.
4. Click the Input Message tab.
5. Enter an input message.

6. Click the Error Alert tab.


7. Select an error alert style.

26
lOMoAR cPSD| 24516743

o Stop: Prevents users from adding invalid data in a cell.


o Warning: Warns that the data entered is invalid, but users can
click Yes to accept the invalid entry, No to edit it, or Cancel to
remove it.
o Information: Informs users that the data entered is invalid, but
users can click OK to accept the invalid entry or Cancel to
remove it.
8. Enter an error alert message.

9. Click OK.
10. Select a cell with an input message.

Now when a cell in the range is selected, the title and message display. If you enter an
invalid value, a custom error message appears.

27
lOMoAR cPSD| 24516743

HOW TO CREATE APPLICATION IN SPREADSHEET AND


MACROS

What Are Excel Macros?

Macros are code that automate work in a program—they let you add your own tiny
features and enhancements to help you accomplish exactly what you need to do, quickly
with just a click of abutton. In a spreadsheet tool like Excel, macros can be especially
powerful. Hidden behind the normal user interface, they are more powerful than standard
functions you enter into a cell (e.g.=IF (A2<100,100, A2)).

These macros make Excel work for you. They replace actions that you do manually—
everything from formatting cells, copying values, and calculating totals. So with a few clicks
you can quickly replace repetitive tasks.

To make these macros, you can simply record your actions in Excel to save them as
repeatable steps or you can use Visual Basic for Applications (VBA), a simple programming
language that's built into Microsoft Office. We'll show you how to use both below, as well
as share examples of Excel macros to help you get started.

Tip: This guide and all examples are written in Excel 2016 for Windows, but the principles
apply to Excel 2007 and newer for both Mac and PC.

Why Use Excel Macros?

Learning how to automate Excel is one of the easiest ways to speed up your work--
especially because Excel is used in so many work processes. Say every week you export
analytics data from your content management system (CMS) to create a report about your
site. The only problem is, those data exports aren't always in an Excel-friendly format.
They're messy and often include far more data than your report requires. This means you
have to clean up empty rows, copy and paste data into the right place, and create your
own charts to visualize data and make it print-friendly. All of these steps may take you
hours to complete.

28
lOMoAR cPSD| 24516743

If there only was a way to press one button and let Excel do it for you in an instant… Well,
can you guess what I’m about to say next?

There is!

All it requires is a little bit of time to set up a macro, and then that code can do the work
for you automatically every time. It's not even as difficult as it sounds.

How to Build Your First Excel Macro

You already know your way around Excel, and are familiar with its grid of cells where you
enter your text and functions. To build Excel macros, though, you'll need an extra tool
that's built into Excel: the Visual Basic Editor.

Before You Proceed: Be sure to download our project file – you’ll need it for later to follow
our Excel macros tutorial.

Meet The VBA Editor

Excel has a built-in tool for writing macros called the Visual Basic Editor—or VBA Editor
for short. To open that, open a spreadsheet and use the shortcut Alt + F11 (for
Mac: Fn + Shift + F11).

The new window that pops up is called the VBA Editor. It's where you'll edit and store all
of your macros. Its layout may look a bit different from this screenshot, but you can move
the windows around to the order you want. Just be sure to keep the Project Explorer pane
open so you can easily edit your macros.

29
lOMoAR cPSD| 24516743

Your macros will be made up of "Modules," or files with your VBA code. You'll add a new
module or open an existing one in the VBA Editor, then type in the code you want. To
insert a module, click "Insert" and then click "Module". You'll then see the blank space to
write your code on the right.

How to Record an Excel Macro

There are two ways to make a macro: code it or record it. The main focus of this article is
on the former, but recording a macro is so simple and handy, it's worth exploring too.
Recording a macro is a good way of getting to know the basics of VBA. Later on, it serves
as handy storage for code that you don’t need to memorize.

When you record a macro, you tell Excel to start the recording. Then you perform the tasks
you want to be translated into VBA code. When you’re done, tell Excel to stop recording
and you can use this new macro to repeat the actions you just performed again and again.

30
lOMoAR cPSD| 24516743

There are limitations to this, so you can't automate every task or become an expert in
automation by only recording. You'll still need to type or edit code manually sometimes.
But it's still a handy way to get started. Here's how: 1. Go to the "View" tab of the ribbon
and click the tiny arrow below the "Macros" button. 2. Then click "Record Macro" 3. Type in
the name of your macro and click "OK" to start the recording. 4. Perform the actions in
your spreadsheet you want to be turned into a macro. 5. When you’re done, go to the
"View" tab, click the tiny arrow below the "Record Macro" button again and select "Stop
recording".

Now, use the shortcut Alt + F11 (for Mac: Fn + Shift + F11) to open the VBA Editor, and
double-click "Module 1" in the Project Explorer.

This is your first code! Amazing, right? You may not have written it yourself, but it’s still
generated from your actions.

Yours probably look different than mine. Can you guess what my code does?

31
lOMoAR cPSD| 24516743

 Sub Makebold is just the text Sub followed by the name I entered when I started
recording.

 The green line doesn’t actually do anything—it's a comment where you could add
an explanation of what the macro does.

 Selection.Font.Bold = True makes the values in the selected cells bold.

 End sub simply tells Excel that the macro stops here.

Now, what will happen if I change the True part of the third line to False? The macro would
then remove any bold formatting from the selection instead of making it bold.

That’s how you record a simple macro. But the real power of macros comes when you can
write it yourself—so let's get started learning to write simple VBA code.

How to Code Your Own Excel Macros

Macros are just bits of code in Excel that do your bidding. Once you write the code in the
VBA Editor, you can run it and let the code work its magic on your spreadsheet. But what's
even better is to build your macro into your spreadsheet, and the best tool for that is
buttons.

So first, before we start coding, let's add a button to run our macro.

Add a Button to Run Your Macro

You can use various Excel objects as buttons for running macros, but I prefer to use a
shape from the "Insert" tab. When you have inserted your shape, right click it and select
"Assign Macro…" Then select the macro you want to run when the shape is clicked—
perhaps the one you just made with a recording and save it by clicking "OK".

32
lOMoAR cPSD| 24516743

Now, when you click the shape which we just turned into a button, Excel will run the macro
without having to open the code each time.

There's one other thing to note before we get started: saving your spreadsheet with
Macros. By default, Excel spreadsheet files with an .xlsx extension cannot include macros.
Instead, when you save your spreadsheet, select the "Excel Macro-Enabled Workbook
(*.xlsm)" format, and add your file name as normal.

Go ahead and do that to save your spreadsheet before we start coding.

Now, let’s get started with actual coding!

Copying and pasting is the simplest way to move data around, but it's still tedious. What if
your spreadsheet could do that for you? With a macro, it could. Let's see how to code a
macro that will copy data and move it around in a spreadsheet.

Open the project file you downloaded earlier and make sure the "Copy, cut, and paste"
sheet is selected. This is a sample employee database with the names, departments, and
salaries of some employees.

33
lOMoAR cPSD| 24516743

Let’s try to copy all the data in columns A through C into D through F using VBA. First,
let's look at the code we need:

Copying Cells with VBA

Copying in VBA is quite easy. Just insert this code into the VBA Editor: Range("Insert range
here").Copy. Here's some examples:

 Range("A:C").Copy ← copies column A through C

 Range("A1:C100").Copy ← copies the range A1:C100

Remember when you recorded a macro before? The macro had Sub
Nameofmacro() and End sub at the top and bottom line of the code. These lines must
always be included. Excel makes that easy, too: When you type in "Sub" followed by the
macro name in the beginning of the code, the End sub is automatically inserted at the
bottom line.

Tip: Remember to enter these lines manually when you’re not using the macro recorder.

Pasting Cells with VBA

Pasting can be done in different ways depending on what you want to paste. 99% of the
time, you’ll need one of these two lines of code:

 Range("The cell/area where you want to paste").Pastespecial ← pastes as normal


(formulas and formatting)

 Range("The cell/area where you want to paste").Pastespecial xlPasteValues ← only


pastes values

Cutting Cells with VBA

34
lOMoAR cPSD| 24516743

If you want to relocate your data instead of copying it, you need to cut it. Cutting is quite
easy and follows the exact same logic as copying.

Here’s the code: Range("Insert range here").Cut

When cutting, you can’t use the ‘PasteSpecial’ command. That means that you can’t paste
values only, or formatting only. Therefore, you need these lines to paste your cells with
VBA: Range("Insert where you want to paste").Select ActiveSheet.Paste

For example, here's the code you'd need to cut the range A:C and paste it into D1:

 Range("A:C").Cut

 Range("D1").Select

 ActiveSheet.Paste

Copying, cutting, and pasting are simple actions that can be done manually without
breaking a sweat. But when you copy and paste the same cells several times a day, a
button that does it for you can save a bunch of time. Additionally, you can combine
copying and pasting in VBA with some other cool code to do even more in your
spreadsheet automatically.

Adding Loops to VBA

I just showed you how to take a simple action (copying and pasting) and attach it to a
button, so you can do it with a mouse click. That's just one automated action. When you
have the code to repeat itself, though, it can do longer and more complex automation
tasks in seconds.

Take a look at the "Loops" sheet in the project file. It’s the same data as in the previous
sheet, but every third row of the data is now moved one column to the right. This type of
faulty data structure is not unusual when exporting data from older programs.

35
lOMoAR cPSD| 24516743

This can take a lot of time to fix manually, especially if the spreadsheet includes thousands
of rows instead of the small sample data in this project file.

Let’s make a loop that fixes it for you. Enter this code in a module, then look at the
explanations below the picture:

1. This line makes sure the loop starts at the top-left cell in the sheet and not
accidentally messes the data up by starting somewhere else.

2. The For i = 1 To 500 line means that the number of times the loop has run
(represented by i) is an increasing number that starts with 1 and ends with 500.
This means that the loop will run 500 times. The number of times the loop should
run depends on the actions you want it to do. Use your good sense here. 500 times
is way too many for our sample dataset, but would fit perfectly if the database had
1500 rows of data.

3. This line recognizes the active cell and tells Excel to move 3 rows down and select
that cell, which then becomes the new active cell. If it was every fourth row that was
misplaced in our data, instead of every third, we could just replace the 3 with a 4 in
this line.

4. This line tells Excel what to do with this newly selected cell. In this case, we want to
delete the cell in such manner that the cells to the right of the cell are moved left.
That is achieved with this line. If we wanted to do something else with the
misplaced rows, this is the place to do it. If we wanted to delete every third row
entirely, then the line should’ve been: Selection.Entirerow.delete.

36
lOMoAR cPSD| 24516743

5. This line tells Excel that there are no more actions within the loop. In this case, 2
and 5 are the frame of the loop and 3 and 4 is the actions within the loop.

When we run this macro, it will result in a neat dataset without any misplaced rows.

Adding Logic to VBA

Logic is what brings a piece of code to life by making it more than just a machine that can
do simple actions and repeat itself. Logic is what makes an Excel-sheet almost human—it
lets it make intelligent decisions on its own. Let’s use that to automate things!

This section is about IF-statements which enables the "if-this-then-that" logic, just like
the IF-function in Excel.

Let’s say the export from our website CMS was even more erroneous than expected. Every
third row is still misplaced, but now, some of the misplaced rows are placed 2 columns to
the right instead of 1 column to the right. Take a look at the sheet "IF-statement" in the
project file to see what it looks like.

How do we take this into account in our macro? We add an IF-statement to the loop!

Let’s formulate what we want Excel to do:

We start in cell A1. Then we go three rows down (to cell A4, A7, A10, etc.) until there’s no
more data. Every time we go three rows down we check this row to see if the data has
been misplaced by 1 or 2 columns. Then move the data in the row either 1 or 2 columns
to the left.

Now, let’s translate this into VBA code. We'll start with a simple loop, as before:

37
lOMoAR cPSD| 24516743

The only thing we need now is to write what should happen within the loop. This is the
"go three rows down" part that we developed back in the section about loops. Now we’re
adding an IF-statement that checks how much the data is misplaced and corrects it
correspondingly.

This is the final code to copy into your module editor, with each step explained below:

1. This is the first part of the IF-statement. It says that if the cell right of the active cell
(or Activecell.Offset(0,1) in VBA code) is blank (represented by = "") then do
something. This something is the exact same action as we did when we created the
loop in the first place: deleting the active cell, and moving the active row one cell to
the left (accomplished with the Selection.Delete Shift:=xlToLeft code). This time, we
do it two times instead of one, because there are two blank cells in the left side of
the row.

38
lOMoAR cPSD| 24516743

2. If the above is not true, and the cell right of the active cell is not blank, then the
active cell is blank. Therefore, we only need to delete the active cell and move the
active row one cell to the left one time.

The IF-statement must always end with an End If to tell Excel it's finished running. After the
IF-statement, the loop can run again and again, repeating the IF-statement each time

Congratulations, you’ve just created a macro that can clean up messy data! See the
animation below to see it in action (If you haven’t already tried it yourself).

Automate Excel Without Macros

Excel macros have only one problem: they're tied to your computer, and they can't run in
the Excel Web App or on your mobile device. And they're best at working on data already
in your spreadsheet, making it difficult to get new data from your other apps into your
spreadsheet.

App integration tool Zapier can help. It connects the Office 365 for Business edition of
Excel to hundreds of other apps—Stripe, Salesforce, Slack, and more—so you can log data
to your spreadsheet automatically or start tasks in other apps right from Excel.

Here's how it works. Say you want to save your Typeform form entries to an Excel
spreadsheet. Just create a Zapier account, and click the Make a Zap button in the top right
corner. Then, select Typeform in the app picker, and set it to watch your form for new
entries.

39
lOMoAR cPSD| 24516743

Zapier can watch your Typeform form for new entries

Test your Zap, then click Continue to add another step to your Zap. This time we'll select
the Excel app, and choose to Add a Row to our spreadsheet. You could also update a row,
or search your spreadsheet for a specific row if you wanted.

Zapier lets you add, update, or find rows in your Excel spreadsheet

Now, choose your spreadsheet and worksheet, then click the + icon on the right of each
spreadsheet row to select the correct form field to save to that spreadsheet row. Save and
test your Zapier integration, then turn it on. Then every time your Typeform form gets
filled out, Zapier will save that data to your Excel spreadsheet.

40
lOMoAR cPSD| 24516743

Zapier can add your form data directly to the spreadsheet row you want

Here are some great ways to get started automating Excel with Zapier in a few clicks—or
build your own Excel integrations to connect your spreadsheets to your favorite apps.

41
lOMoAR cPSD| 24516743

HOW TO CREATE A COLUMN CHART


Column charts are useful for showing data changes over a period of time or for illustrating
comparisons among items. In column charts, categories are typically organized along the
horizontal axis and values along the vertical axis.

For information on column charts, and when they should be used, see Available chart
types in Office.

ExcelOutlook

To create a column chart, follow these steps:

1. Enter data in a spreadsheet.


2. Select the data.
3. Depending on the Excel version you're using, select one of the following options:
 Excel 2016: Click Insert > Insert Column or Bar Chart icon, and select a
column chart option of your choice.

42
lOMoAR cPSD| 24516743

 Excel 2013: Click Insert > Insert Column Chart icon, and select a column
chart option of your choice.

 Excel 2010 and Excel 2007: Click Insert > Column, and select a column
chart option of your choice.

You can optionally format the chart a little further. See the list below for a few
options:

 To apply a different chart style, click Design > Chart Styles, and pick a style.
 To apply a different shape style, click Format > Shape Styles, and pick a
style.
 To apply different shape effects, click Format > Shape Effects, and pick an
option such as Bevel or Glow, and then a sub option.
 To apply a theme, click Page Layout > Themes, and select a theme.
 To apply a formatting option to a specific component of a chart (such
as Vertical (Value) Axis, Horizontal (Category) Axis, Chart Area, to name a
few), click Format > pick a component in the Chart Elements dropdown box,
click Format Selection, and make any necessary changes. Repeat the step for
each component you want to modify.

43
lOMoAR cPSD| 24516743

HOW TO CREATE A BAR CHART

A bar chart (or a bar graph) is one of the easiest ways to present your data in Excel, where
horizontal bars are used to compare data values. Here’s how to make and format bar
charts in Microsoft Excel.
Inserting Bar Charts in Microsoft Excel
While you can potentially turn any set of Excel data into a bar chart, It makes more sense
to do this with data when straight comparisons are possible, such as comparing the sales
data for a number of products. You can also create combo charts in Excel, where bar charts
can be combined with other chart types to show two types of data together.
RELATED: How to Create a Combo Chart in Excel
We’ll be using fictional sales data as our example data set to help you visualize how this
data could be converted into a bar chart in Excel. For more complex comparisons,
alternative chart types like histograms might be better options.
To insert a bar chart in Microsoft Excel, open your Excel workbook and select your data.
You can do this manually using your mouse, or you can select a cell in your range and
press Ctrl+A to select the data automatically.

Once your data is selected, click Insert > Insert Column or Bar Chart.
Various column charts are available, but to insert a standard bar chart, click the “Clustered
Chart” option. This chart is the first icon listed under the “2-D Column” section.

44
lOMoAR cPSD| 24516743

Excel will automatically take the data from your data set to create the chart on the same
worksheet, using your column labels to set axis and chart titles. You can move or resize
the chart to another position on the same worksheet, or cut or copy the chart to another
worksheet or workbook file.
For our example, the sales data has been converted into a bar chart showing a comparison
of the number of sales for each electronic product.

For this set of data, mice were bought the least with 9 sales, while headphones were
bought the most with 55 sales. This comparison is visually obvious from the chart as
presented.
Formatting Bar Charts in Microsoft Excel
By default, a bar chart in Excel is created using a set style, with a title for the chart
extrapolated from one of the column labels (if available).
You can make many formatting changes to your chart, should you wish to. You can change
the color and style of your chart, change the chart title, as well as add or edit axis labels
on both sides.
It’s also possible to add trendlines to your Excel chart, allowing you to see greater patterns
(trends) in your data. This would be especially important for sales data, where a trendline
could visualize decreasing or increasing number of sales over time.

45
lOMoAR cPSD| 24516743

Changing Chart Title Text


To change the title text for a bar chart, double-click the title text box above the chart itself.
You’ll then be able to edit or format the text as required.

If you want to remove the chart title completely, select your chart and click the “Chart
Elements” icon on the right, shown visually as a green, “+” symbol.
From here, click the checkbox next to the “Chart Title” option to deselect it.

Your chart title will be removed once the checkbox has been removed.
Adding and Editing Axis Labels
To add axis labels to your bar chart, select your chart and click the green “Chart Elements”
icon (the “+” icon).
From the “Chart Elements” menu, enable the “Axis Titles” checkbox.

46
lOMoAR cPSD| 24516743

Axis labels should appear for both the x axis (at the bottom) and the y axis (on the left).
These will appear as text boxes.
To edit the labels, double-click the text boxes next to each axis. Edit the text in each text
box accordingly, then select outside of the text box once you’ve finished making changes.

If you want to remove the labels, follow the same steps to remove the checkbox from the
“Chart Elements” menu by pressing the green, “+” icon. Removing the checkbox next to
the “Axis Titles” option will immediately remove the labels from view.
Changing Chart Style and Colors
Microsoft Excel offers a number of chart themes (named styles) that you can apply to your
bar chart. To apply these, select your chart and then click the “Chart Styles” icon on the
right that looks like a paint brush.

A list of style options will become visible in a drop-down menu under the “Style” section.

Select one of these styles to change the visual appearance of your chart, including
changing the bar layout and background.

47
lOMoAR cPSD| 24516743

You can access the same chart styles by clicking the “Design” tab, under the “Chart Tools”
section on the ribbon bar.
The same chart styles will be visible under the “Chart Styles” section—clicking any of the
options shown will change your chart style in the same way as the method above.

You can also make changes to the colors used in your chart in the “Color” section of the
Chart Styles menu.
Color options are grouped, so select one of the color palette groupings to apply those
colors to your chart.

48
lOMoAR cPSD| 24516743

You can test each color style by hovering over them with your mouse first. Your chart will
change to show how the chart will look with those colors applied.
Further Bar Chart Formatting Options
You can make further formatting changes to your bar chart by right-clicking the chart and
selecting the “Format Chart Area” option.

This will bring up the “Format Chart Area” menu on the right. From here, you can change
the fill, border, and other chart formatting options for your chart under the “Chart Options”
section.

You can also change how text is displayed on your chart under the “Text Options” section,
allowing you to add colors, effects, and patterns to your title and axis labels, as well as
change how your text is aligned on the chart.

49
lOMoAR cPSD| 24516743

If you want to make further text formatting changes, you can do this using the standard
text formatting options under the “Home” tab while you’re editing a label.

You can also use the pop-up formatting menu that appears above the chart title or axis
label text boxes as you edit them.

50
lOMoAR cPSD| 24516743

HOW TO CREATE A LINE CHART

Line charts are used to display trends over time. Use a line chart if you have text labels,
dates or a few numeric labels on the horizontal axis. Use a scatter plot (XY chart) to show
scientific XY data.
To create a line chart, execute the following steps.

1. Select the range A1:D7.

2. On the Insert tab, in the Charts group, click the Line symbol.

3. Click Line with Markers.

Result:

51
lOMoAR cPSD| 24516743

Note: only if you have numeric labels, empty cell A1 before you create the line chart. By
doing this, Excel does not recognize the numbers in column A as a data series and
automatically places these numbers on the horizontal (category) axis. After creating the
chart, you can enter the text Year into cell A1 if you like.
Let's customize this line chart.

To change the data range included in the chart, execute the following steps.

4. Select the line chart.

5. On the Design tab, in the Data group, click Select Data.

6. Uncheck Dolphins and Whales and click OK.

Result:
To change the color of the line and the markers, execute the following steps.

7. Right click the line and click Format Data Series.

52
lOMoAR cPSD| 24516743

The Format Data Series pane appears.

8. Click the paint bucket icon and change the line color.

9. Click Marker and change the fill color and border color of the markers.

Result:

To add a trendline, execute the following steps.

10. Select the line chart.

11. Click the + button on the right side of the chart, click the arrow next to Trendline and
then click More Options.

53
lOMoAR cPSD| 24516743

The Format Trendline pane appears.

12. Choose a Trend/Regression type. Click Linear.

13. Specify the number of periods to include in the forecast. Type 2 in the Forward box.

Result:

To change the axis type to Date axis, execute the following steps.

14. Right click the horizontal axis, and then click Format Axis.

The Format Axis pane appears.

15. Click Date axis.

Result:

Conclusion: the trendline predicts a population of approximately 250 bears in 2024.

54
lOMoAR cPSD| 24516743

HOW TO CREATE A PIE CHART


Pie charts are used to display the contribution of each value (slice) to a total (pie). Pie
charts always use one data series.
To create a pie chart of the 2017 data series, execute the following steps.
1. Select the range A1:D2.

2. On the Insert tab, in the Charts group, click the Pie symbol.

3. Click Pie.

Result:

55
lOMoAR cPSD| 24516743

4. Click on the pie to select the whole pie. Click on a slice to drag it away from the center.

Result:

Note: only if you have numeric labels, empty cell A1 before you create the pie chart. By
doing this, Excel does not recognize the numbers in column A as a data series and
automatically creates the correct chart. After creating the chart, you can enter the text Year
into cell A1 if you like.
Let's create one more cool pie chart.

5. Select the range A1:D1, hold down CTRL and select the range A3:D3.

6. Create the pie chart (repeat steps 2-3).

7. Click the legend at the bottom and press Delete.

8. Select the pie chart.

9. Click the + button on the right side of the chart and click the check box next to Data
Labels.

56
lOMoAR cPSD| 24516743

HOW TO CREATE A COMBINED CHART LIKE: COLUMN AND


LINE, COLUMN AND AREA
Suppose I have the data set as shown below and I want to plot both the revenue and
profit margin numbers in the same chart.

To create this combination chart, I first need to create a regular chart where I have all the
above data plotted on it.

Below are the steps to create a regular chart using the above data (the snapshots are of
Excel 2016):

1. Select the Revenue and Profit Margin data (B1:C6 in this example).

2. Click the Insert tab.

3. In the Charts group, click on the ‘Insert Column Chart’ icon.

58
lOMoAR cPSD| 24516743

4. Click on Clustered Column chart. This will insert the chart in the worksheet
area.

5. With the Chart Selected, go to the Design tab and click on Select Data.

6. In the ‘Select Data Source’ dialog box, click on Edit option (below the
‘Horizontal (Category) Axis Labels’).

7. Select years that you want to plot in the chart (A2:A6 in this example).

8. Click OK.

The above steps would give you a chart that has revenue and profit margin plotted as a
clustered column chart. If you can’t see the Profit Margin bar in the chart, it’s because the

59
lOMoAR cPSD| 24516743

value of Profit Margin is very less as compared to the Revenue value (but it’s there as we
can see it’s listed in the legend in orange color).

Now to create a combination chart from this clustered column chart, follow the below
steps:

1. Right-click on any of the bars.

2. Click on ‘Change Series Chart Type

’.

3. In the Change Chart Type dialog box, make sure Combo category is selected
(which it should be by default).

60
lOMoAR cPSD| 24516743

4. Click on the drop-down for Profit Margin.

5. In the drop-down, click on ‘Line with Markers’.

6. Check the Secondary Axis checkbox for Profit Margin.

7. Click OK.

The above steps would give you the combination chart (also called combo chart) as shown
below.

61
lOMoAR cPSD| 24516743

You can now further customize the chart (such as change the title, remove the grid lines,
etc.)

Another good use case of creating combination charts is when you have to show actual vs
target values in the same chart. You can create a simple clustered column chart, or create
something more fancy by converting one bar into markers. Click here to read how to
create an Actual vs Target combination charts in Excel.
Creating Combination Charts in Excel 2010

While the first part of creating a chart is the same in all versions of Excel, converting that
chart into a combination chart is done a bit differently in Excel 2010.

Below are the steps to convert a regular clustered column chart into a combo chart in
Excel 2010:

1. Click on any of the Profit margin bars. This will select all bars for profit
margin.

2. Right-click and select Format Data Series.

62
lOMoAR cPSD| 24516743

3. In the Format Data Series dialogue box, select Secondary Axis (in the Plot
Series On group)

 This will plot Profit Margin Data in a secondary Axis. You would
be able to see a vertical axis on the right of the chart.

4. Right-click and select Change Series Chart Type

5. In the Change Chart Type dialogue box, select Line with Markers option.

63
lOMoAR cPSD| 24516743

HOW TO DISPLAY AN IMAGE IN CHART AREA

All versions of Microsoft Excel allow you to insert pictures stored anywhere on your
computer or another computer you are connected to. In Excel 2016 and Excel 2013, you
can also add an image from web pages and online storages such as OneDrive, Facebook
and Flickr.

Insert an image from a computer

Inserting a picture stored on your computer into your Excel worksheet is easy. All you have
to do is these 3 quick steps:

1. In your Excel spreadsheet, click where you want to put a picture.


2. Switch to the Insert tab > Illustrations group, and click Pictures.

3. In the Insert Picture dialog that opens, browse to the picture of interest, select it,
and click Insert. This will place the picture near the selected cell, more precisely,
the top left corner of the picture will align with the top left corner of the cell.

To insert several images at a time, press and hold the Ctrl key while selecting pictures, and
then click Insert, like shown in the screenshot below:

64
lOMoAR cPSD| 24516743

Done! Now, you can re-position or resize your image, or you can lock the picture to a
certain cell in a way that it resizes, moves, hides and filters together with the associated
cell.

Add picture from the web, OneDrive or Facebook

In the recent versions of Excel 2016 or Excel 2013, you can also add images from web-
pages by using Bing Image Search. To have it done, perform these steps:

1. On the Insert tab, click the Online Pictures button:

2. The following window will appear, you type what you're looking for into the
search box, and hit Enter:

3. In search results, click on the picture you like best to select it, and then
click Insert. You can also select a few images and have them inserted in your
Excel sheet in one go:

65
lOMoAR cPSD| 24516743

If you are looking for something specific, you can filter the found images by size, type,
color or license - just use one or more filters at the top of the search results.

Note. If you plan to distribute your Excel file to someone else, check the picture's copyright
to make sure you can legally use it.

Besides adding images from Bing search, you can insert a picture stored on your
OneDrive, Facebook or Flickr. For this, click the Online Pictures button on the Insert tab,
and then do one of the following:

 Click Browse next to OneDrive, or


 Click the Facebook or Flickr icon at the bottom of the window.

Note. If your OneDrive account does not appear in the Insert Pictures window, most likely
you are not signed in with your Microsoft account. To fix this, click the Sign in link at the
upper right corner of the Excel window.

Paste picture in Excel from another program

The easiest way to insert a picture in Excel from another application is this:

1. Select an image in another application, for example in Microsoft Paint, Word or


PowerPoint, and click Ctrl + C to copy it.
2. Switch back to Excel, select a cell where you want to put the image and
press Ctrl + V to paste it. Yep, it's that easy!

66

You might also like