Sie sind auf Seite 1von 12

Lecture 1

Spreadsheets are widely used software tools for data entry, storage, analysis, and
visualization.
The basic principles are:
1. Be consistent: Use consistent codes for categorical variables. For a categorical
variable like the sex of a mouse in a genetics study, use a single common value for
males (e.g., “male”), and a single common value for females (e.g., “female”). Do not
sometimes write “M,” sometimes “male,” and sometimes “Male.” Pick one and stick to
it.
a. Do not leave any cells empty, Use a consistent fixed code for any missing
values: we would prefer to have “NA” or even a hyphen in the cells with
missing data, to make it clear that the data are known to be missing rather than
unintentionally left blank.
b. Use consistent variable names
c. Use a consistent data layout in multiple files
d. Use consistent file names
e. Use a consistent format for all dates, write dates like YYYY-MM-DD,
f. Be careful about extra spaces within cells
2. Choose good names for things:
a. As a general rule, do not use spaces, either in variable names or file names
b. Be careful about extraneous spaces at the beginning or end of a variable name.
“glucose” is different from “glucose ”
c. Avoid special characters, except for underscores and hyphens. Other symbols
($, @, %, #, &, *, (, ), !, /, etc.) often have special meaning in programming
languages, and so they can be harder to handle.
3. Put just one thing in a cell,
4. Organize the data as a single rectangle (with subjects as rows and variables as
columns, and with a single header row): The best layout for your data within a
spreadsheet is as a single big rectangle with rows corresponding to subjects and
columns corresponding to variables. The first row should contain variable names, and
please do not use more than one row for the variable names.
5. Create a data dictionary: Such a “data dictionary” might contain:
a. The exact variable name as in the data file
b. A version of the variable name that might be used in data visualizations
c. A longer explanation of what the variable means
d. The measurement units
e. Expected minimum and maximum values
6. Do not include calculations in the raw data files
7. Make backups
8. use data validation to avoid data entry errors
9. Do Not Use Font Color or Highlighting as Data
Errors in excel:
If you create a formula in Excel that contains an error or circular reference, Excel lets you
know about it with an error message. A handful of errors can appear in a cell when a formula
or function in Excel cannot be resolved. Knowing their meaning helps correct the problem.

Error Meaning
#DIV/0! Trying to divide by 0
#N/A! A formula or a function inside a formula cannot find the referenced data
#NAME? Text in the formula is not recognized
#NULL! A space was used in formulas that reference multiple ranges; a comma
separates range references
#NUM! A formula has invalid numeric data for the type of operation
#REF! A reference is invalid
#VALUE! The wrong type of operand or function argument is used
Lecture 2
Errors & referencing

Understanding Absolute, Relative, and Mixed Cell References in Excel:

There are three kinds of cell references that you can use in Excel:
 Relative Cell References
 Absolute Cell References
 Mixed Cell References

What are Relative Cell References in Excel?

To calculate the total for each item, we need to multiply the price of each item with the
quantity of that item.
For the first item, the formula in cell D2 would be B2* C2 (as shown below):
Now, instead of entering the formula for all the cells one by one, you can simply copy cell D2
and paste it into all the other cells (D3:D8). When you do it, you will notice that the cell
reference automatically adjust to refer to the corresponding row. For example, the formula
in cell D3 becomes B3*C3 and the formula in D4 becomes B4*C4.

These cell references that adjust itself when the cell is copied are called relative cell
references in Excel.

Absolute Cell References


Unlike relative cell references, absolute cell references don’t change when you copy the
formula to other cells.
For example, suppose you have the data set as shown below where you have to calculate the
commission for each item’s total sales.
The commission is 20% and is listed in cell G1.
To get the commission amount for each item sale, use the following formula in cell E2 and
copy for all cells:
=D2*$G$1

Note that there are two dollar signs ($) in the cell reference that has the commission – $G$2.

What does the Dollar ($) sign do?


A dollar symbol, when added in front of the row and column number, makes it absolute (i.e.,
stops the row and column number from changing when copied to other cells).
For example, in the above case, when I copy the formula from cell E2 to E3, it changes
from =D2*$G$1 to =D3*$G$1.
Note that while D2 changes to D3, $G$1 doesn’t change.
Since we have added a dollar symbol in front of ‘G’ and ‘1’ in G1, it wouldn’t let the cell
reference change when it’s copied.
Hence this makes the cell reference absolute.

When to Use Absolute Cell References in Excel?


Absolute cell references are useful when you don’t want the cell reference to change as you
copy formulas. This could be the case when you have a fixed value that you need to use in the
formula (such as tax rate, commission rate, number of months, etc.)
While you can also hard code this value in the formula (i.e., use 20% instead of $G$2), having
it in a cell and then using the cell reference allows you to change it at a future date.
For example, if your commission structure changes and you’re now paying out 25% instead
of 20%, you can simply change the value in cell G2, and all the formulas would automatically
update.
Mixed Cell References
There can be two types of mixed cell references:
 The row is locked while the column changes when the formula is copied.
 The column is locked while the row changes when the formula is copied.
Below is a data set where you need to calculate the three tiers of commission based on the
percentage value in cell E2, F2, and G2.

Now you can use the power of mixed reference to calculate all these commissions with just
one formula.
Enter the below formula in cell E4 and copy for all cells.
=$B4*$C4*E$2
The above formula uses both kinds of mixed cell references (one where the row is locked
and one where the column is locked).
Let’s analyze each cell reference and understand how it works:
 $B4 (and $C4) – In this reference, the dollar sign is right before the Column notation
but not before the Row number. This means that when you copy the formula to the
cells on the right, the reference will remain the same as the column is fixed. For
example, if you copy the formula from E4 to F4, this reference would not change.
However, when you copy it down, the row number would change as it is not locked.
 E$2 – In this reference, the dollar sign is right before the row number, and the Column
notation has no dollar sign. This means that when you copy the formula down the
cells, the reference will not change as the row number is locked. However, if you copy
the formula to the right, the column alphabet would change as it’s not locked.

"#REF!"
If you see the text "#REF!" in Microsoft Excel or another spreadsheet program, it means the
program has encountered a reference error.
Cells that contain #REF! have an invalid reference to another cell. This may be caused by
mistyping cell labels.
References errors may also occur if formulas are copied and pasted between cells in different
spreadsheets and the spreadsheets don't contain the same cells.
Fixing of # REF! error
 To fix a #REF! error, view the cell contents in the formula field, which is typically
located near the top of the screen. If you can determine which cell the formula should
be referencing, you can replace "#REF!" with the correct cell, such as A3, B5, or $C7.
After you have manually entered the correct cell, the reference error should
disappear and the cell should display the result of the formula.
 If you delete a column, and #REF! errors appear, undo that action (you can use the
shortcut Control + Z). When you undo, the #REF! errors will disappear. Then edit the
formula(s) to exclude the column you want to delete, moving data if needed. Finally,
delete the column and confirm there are no #REF! errors.
 To quickly remove many #REF errors from a worksheet, you can use Find and
Replace. Use the shortcut Control + H to open the Find and Replace dialog. Enter
#REF! in the find input area, and leave the replace input area blank. You can then
make case-by-case changes with Find next + Replace, or use Replace All to replace all
#REF errors in one step.
 Press either F5 or Control-G (Go To) and then select Special. After you do this, the Go
To Special box will appear. Then, select Formulas, and only check the box that says
“Errors.” Click OK. Excel will then take you to every cell that contains an error.
 You can also get a #REF error with the VLOOKUP function if a column isn’t correctly
specified.
Lecture 3
Errors in Excel
##### error
When your cell contains this error code, the column isn't wide enough to display the value.

1. Click on the right border of the column A header and increase the column width.

Tip: double click the right border of the column A header to automatically fit the widest entry
in column A.

#NAME? error
The #NAME? error occurs when Excel can't recognize something. Frequently, the #NAME?
occurs when a function name is misspelled, but there are other causes. Fixing a #NAME?
error is usually just a matter of correcting spelling or a syntax.
Examples
 Function name misspelled (=VLOKUP(E3,B3:C7,2,0), (=SU(A1:A3))
 Range entered incorrectly (=MIN(CC:C7))
 Text value entered without quotes (=LEN(apple))
#VALUE! error
The #VALUE! error appears when a value is not the expected type. This can occur when cells
are left blank, when a function that is expecting a number is given a text value, and when
dates are evaluated as text by Excel. Fixing a #VALUE! error is usually just a matter of
entering the right kind of value.
Examples
 unexpected text value

a. Change the value of cell A3 to a number.


b. Use a function to ignore cells that contain text.

 function argument not expected type (=NETWORKDAYS(I12,I13)), if I13 is not a date


 dates stored as text (June 22 2019)
Lecture 4
Errors in Excel … Cont..

#DIV/0! error
The #DIV/0! error appears when a formula attempts to divide by zero, or a value equivalent
to zero. Like other errors, the #DIV/0! is useful, because it tells you there is something
missing or unexpected in a spreadsheet. You may see #DIV/0! errors when data is being
entered, but is not yet complete. For example, a cell in the worksheet is blank because data
is not yet available.
Although a #DIV/0! error is caused by an attempt to divide by zero. It may also appear in
other formulas that display the #DIV/0! error. For example, if any cell in A1:A5 contains a
#DIV/0! error, the SUM formula below will display #DIV/0!:
Solution:
a. Change the value of cell A2 to a value that is not equal to 0.
b. Prevent the error from being displayed by using the logical function IF.
(=IF(F12=0, "Zero", H8/F12)),
c. =IFERROR(H8/F12,"") // displays nothing when C6 is empty
The best way to prevent #DIV/0! errors is make sure data is complete. If you see an
unexpected #DIV/0! error, check the following:
 All cells used by a formula contain valid information
 There are no blank cells used to divide other values
 The cells referenced by a formula do not already display a #DIV/0! error
Note: if you try to divide a number by a text value, you will see a #VALUE error not #DIV/0!.

#DIV/0! with average functions


Excel has three functions for calculating averages: AVERAGE, AVERAGEIF, and AVERAGEIFS.
All three functions can return a #DIV/0! error when the count of "matching" values is zero.
This is because the general formula for calculating averages is =sum/count, and count can
sometimes be zero.
For example, if you try to average a range of cells that only contains text values, the AVERAGE
function will return #DIV/0! because the count of numeric values to average is zero

#N/A error
The #N/A error appears when something can't be found or identified. It is often a useful
error, because it tells you something important is missing – a product not yet available, an
employee name misspelled, a color option that doesn't exist, etc.
However, #N/A errors can also be caused by extra space characters, misspellings, or an
incomplete lookup table.
The best way to prevent #N/A errors is to make sure lookup values and lookup tables are
correct and complete. If you see an unexpected #N/A error, check the following first:

 The lookup value is spelled correctly and does not contain extra space characters.
 Values in the lookup table are spelled correctly and do not contain extra space.
 Lookup value type = lookup table type (i.e. both are text, both are numbers, etc.)
 Trapping the #N/A error with IFERROR
 Trapping the #N/A error with IFNA (syntax is same as IFERROR)
 Forcing the #N/A error: If you want to force the #N/A error on a worksheet, you can
use the NA function. For example, display #N/A in a cell when A1 equals zero, you can
use a formula like this =IF(A1=0, NA())

#NUM! error
The #NUM! error occurs in Excel formulas when a calculation can't be performed. For
example, if you try to calculate the square root of a negative number, you'll see the #NUM!
error.
This error occurs when:
 Number too big or small: If you try to work with numbers outside the range of excel,
you will receive the #NUM error. For example, raising 10 to the power of 500 (a one
followed by 5000 zeros) is well outside the allowed range. =10^500 // returns
#NUM!
 Impossible calculation

#NULL! Error
The #NULL! error is quite rare in Excel, and is usually the result of a typo where a space
character is used instead of a comma (,) or colon (:) between two cell references.
This error occurs when:
- Space instead of colon/comma

Das könnte Ihnen auch gefallen