DV Unit-II
DV Unit-II
Excel has several predefined styles—or presets—you can use to quickly apply conditional
formatting to your data. They are grouped into three categories:
Color Scales change the color of each cell based on its value. Each color scale uses
a two- or three-color gradient. For example, in the Green-Yellow-Red color scale,
the highest values are green, the average values are yellow, and the lowest values
are red.
In our example, we have a worksheet containing Resource recovery and recycling rates data,
and we'd like to see which landfill percentage in different colors based upon their rates and
highest percent should be in red color and lowest percent should be in green color.
1. Select the desired cells for the conditional formatting rule.
2. From the Home tab, click the Conditional Formatting command. A drop-down menu will
appear.
3. Hover the mouse over the desired conditional formatting type, then select the desired
option from the menu that appears. In our example, we want to have different color
scales. So select Color Scales.
4. Now select the colors Red – yellow – Green Color Scale. This applies the color gradient to
a range of cells. The color indicates where each cell value falls within that range.
Data Bars are horizontal bars added to each cell, much like a bar graph.
To use preset conditional formatting with Data bars:
In our example, we have a worksheet containing Resource Recovery Rates by Region data,
and we'd like to see which State by year is having highest or lowest percent by using Data
bars.
1. Select the desired cells for the conditional formatting rule.
2. From the Home tab, click the Conditional Formatting command. A drop-down menu will
appear.
3. Hover the mouse over the desired conditional formatting type, then select the desired
option from the menu that appears. In our example, we want to have Data bars. So select
Data bars, in that we will have Gradient Fill and Solid Fill, select them to add a coloured
data bar to represent the value in a cell
4. Now select the Green Gradient Fill. You can see that the higher the value, the longer the
bar in the cell
Icon Sets add a specific icon to each cell based on its value.
1. In this example in want to set icons to the values of CAGR column. That is all negative
values should have red colored down arrow, all positive values shouls have green colored
upper arrow and yellow color for zeros.
2. Firstly, copy the values to the next column that is because not to disturb the actual values.
For that, type = in the next cell and select the value i.e.., -3.5% and click enter. Now copy
the formula to rest of the cells just by dragging the formula.
3. Select the desired cells for the conditional formatting to apply icon sets.
4. Click the Conditional Formatting command. A drop-down menu will appear. Hover the
mouse over the desired preset, then choose a preset style from the menu that appears.
Select any 3 scaled icon sets.
5. The conditional formatting will be applied to the selected cells.
6. But we are not getting the exact icons i.e.., for -0.2% we have to get red colored down
arrow but its yellow. So, we have to customize the icons.
7. Select the icons cells and go to conditional formatting and select manage rules. Manage
Rules is to create, edit, delete and view all the conditional formatting rules in the
workbook by using the Conditional Formatting Rules Manager.
8. Select the icon set we have applied previously then a Edit formatting Rule box appers.
Now change the Type to number for both green and yellow icon and change > 0 for green
icon and >=0 for yellow icon by selecting on drop down list. Finally check the Show icon
only check box , that is not to show any values in the cells except icons.Click OK.
The goal is to make important information stand out so you can find it easier.
In our example, we have a worksheet containing Core waste Won PC data, and we'd like to
see the bottom 10 items to be stand out.
1. Select the desired cells for the conditional formatting rule.
2. From the Home tab, click the Conditional Formatting command. A drop-down menu will
appear.
3. Hover the mouse over the desired conditional formatting type, then select the desired
rule from the menu that appears. In our example, we want to highlight bottom 10 items
in green fill. So select Top/Bottom Rules. In that select the Bottom 10 items.
4. A Bottom 10 items box appears, in that select the 10 with Green Fill with dark Green Text.
Click OK.
5. Now, we can see the bottom 10 values has been highlighted with green.
Format Entire Row with Conditional Formatting
In Microsoft Excel, with a few easy steps, you can apply conditional formatting that checks
the value in one cell, and applies formatting to other cells, based on that value. For example,
if I select the state in the dropdown list then we can highlight the states data.
This technique can make key information stand out on your Excel worksheets.
4. The lower section, Edit the Rule Description, changes automatically. Now, it shows a box
where you can enter your custom formula: Click in the box below the heading, Format
values where this formula is true.
5. Enter Conditional Formatting Formula
Any conditional formatting formula must be a test, that gives a TRUE or FALSE result. For
this conditional formatting rule, the formula will do a simple check:
6. Is the dropdown list state is matched with the state in the Selected cells in column B?
TRUE or FALSE
7. Row and Column Reference
Before you create a conditional formatting rule, it's important to check which cell is active
on the worksheet. If the formula will have cell references, they might need to refer to the
active cell's row and/or column.
In this example, cells B5:I12 are selected.
Cell B5 is the active cell
Formula should check the value in cells of column B-- the active cell's column
Formula would work for the active cell is =B5=K1
Formula will need the correct type of reference to cell B2
Relative or Absolute Reference
In Excel, a cell reference can be an absolute, relative reference, or mixed reference. Which
type of reference should be used in this conditional formatting formula?
Note: In a cell reference, a dollar sign ($) tells Excel to lock that part of the reference
Absolute: $B$5 -- both the column ($B) and the row ($2) references are locked with dollar
signs
All cells would check the value in worksheet cell B2
Relative: B5 -- neither the column or the row are locked with a dollar sign
All cells would check value in their own row
All cells would check the value in the column to their immediate right, because column B
is to the right of the active cell, A2
9. Add Formatting
The purpose of conditional formatting is to highlight cells that meet the criteria rules. In
this example, the cells should turn blue, if the formula result is TRUE. That will highlight
the rows, so they're easy to spot in a long list.
Follow these steps, to set the formatting:
In the New Formatting Rule dialog box, click the Format button.
In the Format Cells dialog box, select the formatting options that you want.
In this example a blue fill color was selected and white color font is selected.
You could also select format options from the Border, and Number formatting tabs
11. On the worksheet, the new conditional formatting rule is applied. Row with the state
selected in drop down list are highlighted with blue fill colour.
Incorrect Highlighting
If we use a relative reference -- B -- without the $ sign, the column reference would adjust
automatically, in each column of the selected range. Instead of referring to column B, each
column would refer to the column to its right. That would give incorrect highlighting with the
conditional formatting.
An Excel macro is an action or a set of actions that can be recorded, named, saved and
executed as many times as required and whenever desired. By using macros, we are able to
automate repetitive tasks associated with data manipulation and data reporting that must be
accomplished repeatedly.
Sample Data
In this example, we will add the headers and some formatting to our sample data and then
perform the same steps with the macro shortcut key.
The Developer tab is hidden on the ribbon by default. To customize the ribbon, follow these
steps:
Right-click on the ribbon, anywhere and select (by clicking) Customize the ribbon.
Navigate to Customize the ribbon and place a check on the Developer checkbox.
Record a Macro
Now that we have the developer tab on our ribbon, let’s start recording our first macro in
Excel. To record a macro, follow these steps:
Note: Every step you perform from now on will be recorded by the macro.
Let’s now add headers and format them with some colors.
Once you are done, go back to the developer tab and click stop recording.
Your macro has recorded the steps, and you can now perform the same steps with the
shortcut key you have assigned in the Record Macro dialog box.
Add a Button to Run Your Macro
In Excel, you can create a button that will run your macro. To do that, follow the steps below:
Go to illustrations > Shapes and select any shape. We will use a rectangle with rounded
corners.
You can also insert a button by going to the Developer tab > Insert > Form Controls.
Add the text to the shape by right-clicking the shape and selecting edit text.
Right-click the shape and select Assign Macro.
Select the corresponding macro from the window and select (by clicking) Ok.
Consequently, whenever you select (by clicking) that shape, Microsoft Excel will activate and
run your recorded macro.
Visualizations with Sparklines and Shapes
The sparklines are also known as in-line charts. So the question is where do we use sparklines,
we can use them in situations where we want the graph/chart to be as near to the data as
possible. Mainly we write data in one row / one column and add a sparkline to the end of the
row or end of the column. Sparklines can be of many types: Line, Column and Win/Loss. An
example of a sparkline is as follows:
An example of sparkline
Method of adding sparkline:
Follow the below steps to add sparkline in Excel:
Go to insert tab.
Select the cell where you want to insert sparkline.
To format the sparkline, select the sparkline you want to format and then select the Sparkline
option on the menubar as shown in the picture below:
Formatting the sparkline
Using show submenu:
In the show submenu there are 6 options:
Negative Points: Marks the negative points in the graph with a different color which is
illustrated in the figure below:
Negative Points marker marks the negative points with different color
Using Style submenu:
In the style submenu, we can select the style of the sparkline, many options are available
(different variety of colors). We can also set the color of the sparkline and marker color using
Sparkline Color and Marker Color options.
You can add shapes to your spreadsheet to spark a little visual interest. By using the Shapes
menu, you can choose from dozens of different types of shapes.
Insert a Shape
1. Click the Insert tab.
2. Click the Shapes button.
The Shapes menu displays all the types of shapes available, organized into groups.
Now the cursor changes to a cross hair and is ready to draw on the sheet.
Format a Shape
Once you’ve added a shape, you can use the Format tab to change its style, fill, outline color,
and effects.
1. Select a shape.
When you select a shape, the Format tab in the Drawing Tools ribbon group becomes
available. Double-click a shape to automatically switch to the Format tab.
2. Use the Shape Style options on the Format tab to change the style, fill color, outline, or
shape effects.
Select a style from the Shape Styles gallery, or click the gallery’s More button to see
all available styles.
Select a shape fill color, weight, or dash pattern.
Select a shape outline color to change the color of the selected shape. You can also fill
it with a gradient, picture, or texture pattern.
Apply various shape effects such as shadow, reflection, glow, bevel, and 3D rotation.
Custom number formats
Number format?
A number format is a special code to control how a value is displayed in Excel. For example,
the table below shows 7 different number formats applied to the same date, January 1, 2019:
On the home tab of the ribbon, you'll find a menu of build-in number formats. Below this
menu to the right, there is a small button to access all number formats, including custom
formats:
This button opens the Format Cells dialog box. You'll find a complete list of number formats,
organized by category, on the Number tab:
Note: you can open Format Cells dialog box with the keyboard shortcut Control + 1.
General is default
By default, cells start with the General format applied. The display of numbers using the
General number format is somewhat "fluid". Excel will display as many decimal places as
space allows, and will round decimals and use scientific number format when space is limited.
The screen below shows the same values in column B and D, but D is narrower and Excel
makes adjustments on the fly.
How to change number formats
You can select standard number formats (General, Number, Currency, Accounting, Short
Date, Long Date, Time, Percentage, Fraction, Scientific, Text) on the home tab of the ribbon
using the Number Format menu.
Note: As you enter data, Excel will sometimes change number formats automatically. For
example if you enter a valid date, Excel will change to "Date" format. If you enter a percentage
like 5%, Excel will change to Percentage, and so on.
Note: Custom number formats live in a workbook, not in Excel generally. If you copy a value
formatted with a custom format from one workbook to another, the custom number format
will be transferred into the workbook along with the value.
Tip: if you want base your custom format on an existing format, first apply the base format,
then click the "Custom" category and edit codes as you like.
This structure can make custom number formats look overwhelmingly complex. To read a
custom number format, learn to spot the semi-colons and mentally parse the code into these
sections:
1. Positive values
2. Negative values
3. Zero values
4. Text values
Conditionals
Custom number formats also up to two conditions, which are written in square brackets like
[>100] or [<=100]. When you use conditionals in custom number formats, you override the
standard [positive];[negative];[zero];[text] structure. For example, to display values below
100 in red, you can use:
[Red][<100]0;0
To display values greater than or equal to 100 in blue, you can extend the format like this:
[Red][<100]0;[Blue][>=100]0
To apply more than two conditions, or to change other cell attributes, like fill color, etc. you'll
need to switch to Conditional Formatting, which can apply formatting with much more power
and flexibility using formulas.
Colors by index
In addition to color names, it's also possible to specify colors by an index number
(Color1,Color2,Color3, etc.) The examples below are using the custom number
format: [ColorX]0"▲▼", where X is a number between 1-56:
[Color1]0"▲▼" // black
[Color2]0"▲▼" // white
[Color3]0"▲▼" // red
[Color4]0"▲▼" // green etc.
The triangle symbols have been added only to make the colors easier to see. The first image
shows all 56 colors on a standard white background. The second image shows the same colors
on a gray background. Note the first 8 colors shown correspond to the named color list above.