56
Computing Tools Computing Tools for Engineering for Engineering Design Design ( ( ENME ENME 337 H(3-2)) Instructor: Instructor: Dr. Daniel Y. Kwok Dr. Daniel Y. Kwok Office: ME321 Office: ME321 Phone: 210-8428 Phone: 210-8428 E-mail: E-mail: [email protected] [email protected] “Spreadsheet Basics” Fig.: 4-line to 1-line multiplexer

Computing Tools for Engineering Design ( ENME 337 H(3-2))

Embed Size (px)

DESCRIPTION

Computing Tools for Engineering Design ( ENME 337 H(3-2)). “Spreadsheet Basics”. Instructor: Dr. Daniel Y. Kwok Office: ME321 Phone: 210-8428 E-mail: [email protected]. Fig.: 4-line to 1-line multiplexer. What is a Spreadsheet ?. - PowerPoint PPT Presentation

Citation preview

Page 1: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Computing Tools Computing Tools for Engineering for Engineering

DesignDesign((ENME ENME 337 H(3-2))

Instructor:Instructor:Dr. Daniel Y. KwokDr. Daniel Y. Kwok

Office: ME321Office: ME321Phone: 210-8428Phone: 210-8428

E-mail: [email protected]: [email protected]

“Spreadsheet Basics”

Fig.: 4-line to 1-line multiplexer

Page 2: Computing Tools for Engineering Design ( ENME  337 H(3-2))

What is a What is a SpreadsheetSpreadsheet ? ?

A spreadsheet is a rectangular table (or grid) of information. (It is, therefore, a kind of matrix.)

The word came from "spread" in its sense of a newspaper or magazine item (text and/or graphics) that covers two facing pages, extending across the center fold and treating the two pages as one large one.

The compound word "spread-sheet" came to mean the format used to present bookkeeping ledgers -- with columns for categories of expenditures across the top, invoices listed down the left margin, and the amount of each payment in the cell where its row and column intersect, for example -- which were traditionally a "spread" across facing pages of a bound ledger (= book for keeping accounting records) or on oversized sheets of paper ruled into rows and columns in that format and approximately twice as wide as ordinary paper.

Page 3: Computing Tools for Engineering Design ( ENME  337 H(3-2))

What is a What is a spreadsheet?spreadsheet?

A spreadsheet is the computer equivalent of a paper ledger sheet. It consists of a grid made from columns and rows. It is an environment that can make number manipulation easy and somewhat painless.

The math that goes on behind the scenes on the paper ledger can be overwhelming. If you change the loan amount, you will have to start the math all over again (from scratch). But let's take a closer look at the computer version.

Page 4: Computing Tools for Engineering Design ( ENME  337 H(3-2))

So why do it on a So why do it on a computer?computer? Looking at our previous example it seems pretty evenly matched. Right?

WRONG! The nice thing about using a computer and spreadsheet is that you can experiment with numbers without having to RE-DO all the calculations.

Lets change the interest rate and then the number of months. Let the COMPUTER do the calculations! Once we have the formulas set up, we can change the variables that are called from the formula and watch the changes.

Example: Change the Interest Rate

Do that on paper and you better get your calculator back out and get an Eraser and hope you punched all the right keys and in the right order.Spreadsheets are instantly updated if one of the entries is changed. NO erasers! NO new formulas! NO calculators! Spreadsheets can be very valuable tools in business. They are often used to play out a series of what-if scenarios! (much like our car purchase here.)

Page 5: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Origins of the Origins of the SpreadsheetSpreadsheet

The concept of an electronic spreadsheet was outlined in the 1961 paper "Budgeting Models and System Simulation" by Richard Mattessich. Some credit for the computerized spreadsheet perhaps belongs to Pardo and Landau, who filed a patent (U.S. Patent no. 4,398,249) on some of the related algorithms in 1970. While the patent was originally rejected by the patent office as being a purely mathematical invention, Pardo and Landau won a court case establishing that "something does not cease to become patentable merely because the point of novelty is in an algorithm." This case helped establish the viability of Software patents.The generally recognized inventor of the spreadsheet is Dan Bricklin. Bricklin has spoken of watching his university professor create a table of calculation results on a blackboard. When the professor found an error, he had to tediously erase and rewrite a number of sequential entries in the table, triggering Bricklin to think that he could replicate the process on a computer, using a blackboard/spreadsheet paradigm to view results of underlying formulas.His idea became VisiCalc, the first spreadsheet, and the "killer application" that turned the personal computer from a hobby for computer enthusiasts into a business tool..

Page 6: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Microsoft Microsoft ExcelExcel

ExcelMicrosoft Excel clearly dominates the spreadsheet market. Not too long ago, Lotus 1-2-3 was considered the "standard" spreadsheet. Excel now holds that distinction, with an estimated 90% market share.

The table below lists the various versions of Excel for Windows that you may encounter.

Page 7: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Version

Released

Comments

1 1985 Version 1, for the Macintosh was released.

2 1987 The first Windows version was labeled "2" to correspond to the Mac version. This included a run-time version of Windows.

3 1990 The first "popular" version. Included lots of usability features.

4 1992 The first "popular" version. Included lots of usability features.

5 1993 A major upgrade. Included multi-sheet workbooks and support for VBA.

7* 1995 Known as Excel 95. The first major 32-bit version of Excel**. Feature-wise, it's very similar to Excel 5.

8 1997 Known as Excel 97. A new interface for VBA developers, UserForms, data validation, and lots more.

9 1999 Known as Excel 2000. Can use HTML as a native file format, "self-repair" capability, enhanced clipboard, pivot charts, modeless user forms.

10 2001 Known as Excel 2002, this is part of Office XP. It has a long list of new features, but most of them will probably be of little value to the majority of users. Perhaps the most significant feature is the ability to recover your work when Excel crashes. This version features product activation technology (i.e., copy protection). Please consider the ramifications of this before deciding whether to upgrade. 

11 2003 It's called Microsoft Office Excel 2003.The new features in this version are: (a) improved support for XML, (b) a new "list range" feature, (c) Smart Tag enhancements, and (d) corrected statistical functions. Most users will not find the upgrade worthwhile. Read John Walkenbach's Excel 2003 Review.

* There is no Excel 6. Beginning with Excel 7, the version numbering was changed so all of the Microsoft Office applications would have the same version number.** There was also 32-bit version of Excel 5, but it was not widely distributed.

Page 8: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Basics of a SpreadsheetBasics of a Spreadsheet So let's get started digging into what makes a spreadsheet

work.Spreadsheets are made up of

columns rows and their intersections are called cells

In each cell there may be the following types of data text (labels) number data (constants) formulas (mathematical equations that do all the

work)

Take a look at the explanations of each of these.

Page 9: Computing Tools for Engineering Design ( ENME  337 H(3-2))

What is a Column?What is a Column? In a spreadsheet the In a spreadsheet the COLUMNCOLUMN is defined as the vertical is defined as the vertical

space that is going up and down the window. space that is going up and down the window. LettersLetters are are used to designate each used to designate each COLUMN'SCOLUMN'S location. location.

In the above diagram the COLUMN labeled C is highlighted.

Page 10: Computing Tools for Engineering Design ( ENME  337 H(3-2))

What is a Row?What is a Row?

In a spreadsheet the In a spreadsheet the ROWROW is defined as the horizontal is defined as the horizontal space that is going across the window. space that is going across the window. NumbersNumbers are used are used to designate each to designate each ROW'SROW'S location. location.

In the above diagram the ROW labeled 4 is highlighted.

Page 11: Computing Tools for Engineering Design ( ENME  337 H(3-2))

What is a CELL ? In a spreadsheet the In a spreadsheet the CELLCELL is defined as the space where a is defined as the space where a

specified row and column intersect. Each specified row and column intersect. Each CELLCELL is assigned a is assigned a name according to its name according to its COLUMN letterCOLUMN letter and and ROW numberROW number. .

In the above diagram the CELL labeled B6 is highlighted. When referencing a cell, you should put the column first and the row second.

Page 12: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Types of Data In a spreadsheet there are three basic types of data that can be

entered. labels - (text with no numerical value) constants - (just a number -- constant value) formulas* - (a mathematical equation used to calculate)

data types examples descriptions

LABEL Name or Wage or Days

anything that is just text

CONSTANT 5 or 3.75 or -7.4 any number

FORMULA =5+3 or = 8*5+3

math equation

*ALL formulas MUST begin with an equal sign (=)

Page 13: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Labels in ExcelLabels in Excel

LabelsLabels are text entries. They do not have a value are text entries. They do not have a value associated with them. We typically use labels to identify associated with them. We typically use labels to identify what we are talking about.what we are talking about.

In our first example: the labels are:

• computer ledger • car loan • interest • # of payments • Monthly Pmt.

Again, we use labels to help identify what we are talking about. The labels are NOT for the computer but rather for us so that we can clarify what we are doing.

Page 14: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Constants in ExcelConstants in Excel ConstantsConstants are entries that have a specific fixed value. If are entries that have a specific fixed value. If

someone asks you how old you are, you would answer with a someone asks you how old you are, you would answer with a specific answer. Sure, other people will have different specific answer. Sure, other people will have different answers, but it is a fixed value for each person.answers, but it is a fixed value for each person.

In our first example: the constants were :

• $12,000 • 9.6% • 60

As you can see from these examples there may be different types of numbers. Sometimes constants are referring to dollars, sometimes referring to percentages, and other times referring to a number of items (in this case 60 months). These are typed into the computer with just the numbers and are changed to display their type of number by formatting (we will talk about this later). Again, we use constants to enter FIXED number data.

Page 15: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Formulas in ExcelFormulas in Excel FormulasFormulas are entries that have an equation that calculates the are entries that have an equation that calculates the

value to display. We DO NOT type in the numbers we are looking value to display. We DO NOT type in the numbers we are looking for; we type in the equation. This equation will be updated upon for; we type in the equation. This equation will be updated upon the change or entry of any data that is referenced in the equation.the change or entry of any data that is referenced in the equation.

In our first example, the solution was $252.61This was NOT typed into the keyboard.The formula that was typed into the spreadsheet was:=PMT(C4/12,C5,-C3)C4 (annual interest rate) was divided by 12 because there are 12 months in a year. Dividing by 12 will give us the interest rate for the payment period – in this case a payment period of one month.

Page 16: Computing Tools for Engineering Design ( ENME  337 H(3-2))

It is also important to type in the reference to the It is also important to type in the reference to the constants instead of the constants. constants instead of the constants.

Had I entered =PMT(.096,60,-12000) my formula Had I entered =PMT(.096,60,-12000) my formula would only work for that particular set of data. I would only work for that particular set of data. I could change the months above and the payment could change the months above and the payment would not change. Remember to enter the cell would not change. Remember to enter the cell where the data is stored and NOT the data itself. where the data is stored and NOT the data itself.

Formulas are mathematical equations. There is a Formulas are mathematical equations. There is a list of the functions available within Excel under list of the functions available within Excel under the the menumenu INSERTINSERT down to down to FunctionFunction. .

Formulas OR Formulas OR FunctionsFunctions MUST BEGINMUST BEGIN with an with an equal sign (=). equal sign (=).

Again, we use Again, we use formulasformulas to CALCULATE a value to to CALCULATE a value to be displayed. be displayed.

Page 17: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Basic Formulas in ExcelBasic Formulas in Excel When we are entering formulas into a spreadsheet we want to When we are entering formulas into a spreadsheet we want to

make as many references as possible to existing data. If we make as many references as possible to existing data. If we can reference that informationcan reference that information we we don't have to type it don't have to type it in againin again. AND more importantly if that OTHER information . AND more importantly if that OTHER information changes, we changes, we DO-NOT have to change the equationsDO-NOT have to change the equations..

For example, iFor example, if f youyou work for 23 hours and make $5.36 an hour, work for 23 hours and make $5.36 an hour, how much do you make? We can set up this situation using how much do you make? We can set up this situation using

three labels three labels two constants two constants one equationone equation

Let's look at this equation in B4:

• = B1 * B2 • = 23 * 5.36

Both of these equations will produce the same answers, but one is much more useful than the other. DO YOU KNOW which is BEST and WHY?

It is BEST if we can Reference as much data as possible as opposed to typing data into equations.

Page 18: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Change in FormulasChange in Formulas In our last example, things were pretty straightforward. We had In our last example, things were pretty straightforward. We had

number of hours worked multiplied by wage per hour and we got number of hours worked multiplied by wage per hour and we got our total pay. Once you have a working spreadsheet you can save our total pay. Once you have a working spreadsheet you can save your work and use it at a later time. If we referenced the actual your work and use it at a later time. If we referenced the actual cells (instead of typing the data into the equation) we could cells (instead of typing the data into the equation) we could update the entire spreadsheet by just typing in the NEW Hours update the entire spreadsheet by just typing in the NEW Hours worked. And -- you're done! worked. And -- you're done!

Let's look at the new spreadsheet:• hours have been changed to 34 • wage is the same • total pay would now be = 34 * 5.36 • but would still be = B1 * B2

If we had typed in ( = 23 * 5.36 ) the first time and just changed the hours worked, our equation in B4 would still be ( = 23 * 5.36 )INSTEAD we typed in references to the data that we wanted to use in the equation. We typed in ( = B1 * B2 ). These are the locations of the data that we want to use in our equation. It is BEST if we can Reference as much data as possible as opposed to typing data into equations.

Page 19: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Basic Math FunctionsBasic Math Functions Spreadsheets have many Math functions built into them. Of the Spreadsheets have many Math functions built into them. Of the

most basic operations are the standard multiply, divide, add and most basic operations are the standard multiply, divide, add and subtract. These operations follow the order of operations (just like subtract. These operations follow the order of operations (just like

algebra). Let's look at some examples.algebra). Let's look at some examples.

A B

1 55 33

2 77 44

3 88 66

For these following examples lets consider the following data: A1 (column A, row 1) = 5 A2 (column A, row 2) = 7 A3 (column A, row 3) = 8 B1 (column B, row 1) = 3 B2 (column B, row 2) = 4 B3 (column B, row 3) = 6

Operation Symbol

Constant Data Referenced Data

Answer

Multiplication

* = 5 * 6 = A1 * B3 30

Division / = 8 / 4 = A3 / B2 2

Addition + = 4 + 7 = B2 + A2 11

Subtraction -- = 8 - 3 = 8 - 3 = A3 - B1 = A3 - B1 55

Page 20: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Methods of Selecting Methods of Selecting CellsCells

Selecting cellsSelecting cells in an equation is a very important in an equation is a very important concept of a spreadsheet. We need to know how to concept of a spreadsheet. We need to know how to reference the data in other parts of the spreadsheet. When reference the data in other parts of the spreadsheet. When entering your selectionentering your selection,, you may use the keyboard or the you may use the keyboard or the mouse. mouse.

We can select several cells together if we can specify a We can select several cells together if we can specify a starting cell and a stopping cell. This will select ALL the starting cell and a stopping cell. This will select ALL the cells within this specified BLOCK of cells. cells within this specified BLOCK of cells.

If the cells that we want to work with are not together If the cells that we want to work with are not together (non-contiguous cells) we can use the comma to separate (non-contiguous cells) we can use the comma to separate the cells or by holding down the control-key (command the cells or by holding down the control-key (command key on a MAC) and selecting cells or blocks of cells the key on a MAC) and selecting cells or blocks of cells the comma will be inserted automatically to separate these comma will be inserted automatically to separate these chunks of data. chunks of data.

Page 21: Computing Tools for Engineering Design ( ENME  337 H(3-2))

For the following examples lets consider the table For the following examples lets consider the table below: below:

A1 (column A, row 1) = 5 A1 (column A, row 1) = 5 A2 (column A, row 2) = 7 A2 (column A, row 2) = 7 A3 (column A, row 3) = 8 A3 (column A, row 3) = 8 B1 (column B, row 1) = 3 B1 (column B, row 1) = 3 B2 (column B, row 2) = 4 B2 (column B, row 2) = 4 B3 (column B, row 3) = 6B3 (column B, row 3) = 6

A B

1 55 33

2 77 44

3 88 66

This is just a discussion of selection methods. If we wanted to add the cells in the (To Select) you would type in

=sum(Type In) or

=sum(Click On)

Page 22: Computing Tools for Engineering Design ( ENME  337 H(3-2))

To Select Type In Click On A1 A1 A1 A1 click on A1 click on A1

A1, A2, A3 A1, A2, A3 A1:A3 A1:A3 click on A1click on A1with button downwith button downdrag to A3drag to A3

A1, B1 A1, B1 A1:B1 A1:B1 click on A1 click on A1 with button down with button down drag to B1drag to B1

A1, B3 A1, B3 A1, B3 A1, B3 click on A1click on A1type in comma type in comma (or hold down the control (or hold down the control key on a PC)key on a PC)(or hold down the (or hold down the command key on a MAC) command key on a MAC) click on B3click on B3

A1, A2, B1, B2 A1, A2, B1, B2 A1:B2 A1:B2 click on A1click on A1with button downwith button downdrag to B2drag to B2

Page 23: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Specific Formulas (or Specific Formulas (or FUNCTIONS)FUNCTIONS)

Page 24: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Sum FunctionSum Function Probably the most popular function in any Probably the most popular function in any

spreadsheet is the SUM function. The Sum function spreadsheet is the SUM function. The Sum function takes all of the values in each of the specified cells takes all of the values in each of the specified cells and totals their values. The syntax is: and totals their values. The syntax is:

=SUM(first value, second value, etc) =SUM(first value, second value, etc)

In the first and second spots you can enter any of the In the first and second spots you can enter any of the following (constant, cell, range of cells). following (constant, cell, range of cells).

Blank cells will return a value of zero to be added Blank cells will return a value of zero to be added to the total. to the total.

Text cells can not be added to a number and will Text cells can not be added to a number and will produce an error. produce an error.

Lets use the table here for the discussion that follows: Lets use the table here for the discussion that follows: We will look at several different specific examples We will look at several different specific examples that show how the typical function can be used! that show how the typical function can be used! Notice that in A4 there is a TEXT entry. This has NO Notice that in A4 there is a TEXT entry. This has NO numeric value and can not be included in a total.numeric value and can not be included in a total.

AA

11 2525

22 5050

33 7575

44 testtest

55

Page 25: Computing Tools for Engineering Design ( ENME  337 H(3-2))

ExampleExample Cells to Cells to ADDADD

AnsweAnswerr

=sum (A1:A3)=sum (A1:A3) A1, A2, A3A1, A2, A3 150150

=sum (A1:A3, =sum (A1:A3, 100)100)

A1, A2, A3 and A1, A2, A3 and 100 100

250250

=sum (A1+A4)=sum (A1+A4) A1, A4A1, A4 #VALUE!#VALUE!

=sum (A1:A2, =sum (A1:A2, A5)A5)

A1, A2, A5A1, A2, A5 7575

AA

11 2525

22 5050

33 7575

44 testtest

55

Examples:Examples:

Page 26: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Average FunctionAverage Function There are many functions built into many There are many functions built into many

spreadsheets. One of the first ones that we spreadsheets. One of the first ones that we are going to discuss is the are going to discuss is the AverageAverage function. function. The average function finds the average of the The average function finds the average of the specified data. specified data. (Simplifies adding all of the (Simplifies adding all of the indicated cells together and dividing by the indicated cells together and dividing by the total number of cells.)total number of cells.) The syntax is as The syntax is as follows. follows.

=Average (first value, second value, etc.)=Average (first value, second value, etc.)

Text fields and blank entries are not included Text fields and blank entries are not included in the calculations of the Average Function. in the calculations of the Average Function.

Lets use the table here for the discussion that Lets use the table here for the discussion that follows: follows: We will look at several different specific We will look at several different specific examples that show how the average function examples that show how the average function can be used! can be used!

AA

11 2525

22 5050

33 7575

44 100100

55

Page 27: Computing Tools for Engineering Design ( ENME  337 H(3-2))

ExampleExample Cells to Cells to AverageAverage

AnswerAnswer

=average=average (A1:A4)(A1:A4) A1, A2, A3, A4A1, A2, A3, A4 62.562.5

= average(A1:A4, = average(A1:A4, 300)300)

A1, A2, A3, A4 A1, A2, A3, A4 and 300 and 300

110110

= average(A1:A5)= average(A1:A5) A1, A2, A3, A1, A2, A3, A4, A5A4, A5

62.562.5

= average(A1:A2, = average(A1:A2, A4)A4)

A1, A2, A4A1, A2, A4 58.3358.33

AA

11 2525

22 5050

33 7575

44 100100

55

Examples:Examples:

Page 28: Computing Tools for Engineering Design ( ENME  337 H(3-2))

MAX FunctionMAX Function The next function we will discuss is The next function we will discuss is MaxMax (which (which

stand for Maximum). This will return the stand for Maximum). This will return the largest (max) value in the selected range of largest (max) value in the selected range of cells. cells.

Blank entries are not included in the Blank entries are not included in the calculations of the Max Function. calculations of the Max Function.

Text entries are not included in the Text entries are not included in the calculations of the Max Function. calculations of the Max Function.

Lets use the table here for the discussion that Lets use the table here for the discussion that follows.follows.

We will look at several different specific We will look at several different specific examples that show how the Max functions examples that show how the Max functions can be used! that show how the average can be used! that show how the average function can be used! function can be used!

AA

11 1010

22 2020

33 3030

44 testtest

55

Page 29: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Example of Example of MaxMax

Cells to Cells to look atlook at

Ans. Ans. MaxMax

=max=max (A1:A4)(A1:A4) A1, A2, A3, A4A1, A2, A3, A4 3030

=max (A1:A4, 100)=max (A1:A4, 100) A1, A2, A3, A4 A1, A2, A3, A4 and 100 and 100

100100

=max (A1, A3)=max (A1, A3) A1, A3A1, A3 3030

=max (A1, A5)=max (A1, A5) A1, A5A1, A5 1010

AA

11 1010

22 2020

33 3030

44 testtest

55

Examples:Examples:

Page 30: Computing Tools for Engineering Design ( ENME  337 H(3-2))

MIN FunctionMIN Function The next function we will discuss is The next function we will discuss is MinMin (which (which

stands for minimum). This will return the stands for minimum). This will return the smallest (Min) value in the selected range of smallest (Min) value in the selected range of cells. cells.

Blank entries are not included in the Blank entries are not included in the calculations of the Min Function. calculations of the Min Function.

Text entries are not included in the Text entries are not included in the calculations of the Min Function. calculations of the Min Function.

Lets use the table here for the discussion that Lets use the table here for the discussion that follows. follows. We will look at several different specific We will look at several different specific examplesexamples that show how the min functions can be that show how the min functions can be used!used!

AA

11 1010

22 2020

33 3030

44 testtest

55

Page 31: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Example of MinExample of Min Cells to Cells to look atlook at

Ans. Ans. MinMin

= min= min (A1:A4)(A1:A4) A1, A2, A3, A4A1, A2, A3, A4 1010

= min (A2:A3, 100)= min (A2:A3, 100) A2, A3 and A2, A3 and 100 100

2020

= min (A1, A3)= min (A1, A3) A1, A3A1, A3 1010

= min (A1, A5)= min (A1, A5) A1, A5 A1, A5 (displays the (displays the smallest smallest numbernumber))

1010

AA

11 1010

22 2020

33 3030

44 testtest

55

Examples:Examples:

Page 32: Computing Tools for Engineering Design ( ENME  337 H(3-2))

COUNT FunctionCOUNT Function The next function we will discuss is The next function we will discuss is CountCount. .

This will return the number of entries This will return the number of entries (actually counts each cell that contains (actually counts each cell that contains number data) in the selected range of cells. number data) in the selected range of cells.

Blank entries are not counted. Blank entries are not counted. Text entries are Text entries are NOTNOT counted. counted.

Lets use the table here for the discussion that Lets use the table here for the discussion that follows. follows. We will look at several different specific We will look at several different specific examples that show how the Count examples that show how the Count functions can be used!functions can be used!

AA

11 1010

22 2020

33 3030

44 testtest

55

Page 33: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Example of Example of CountCount

Cells to Cells to look atlook at

AnsweAnswerr

= Count= Count (A1:A3)(A1:A3) A1, A2, A3A1, A2, A3 33

= Count (A1:A3, 100)= Count (A1:A3, 100) A1, A2, A3 and A1, A2, A3 and 100 100

44

= Count (A1, A3)= Count (A1, A3) A1, A3A1, A3 22

= Count (A1, A4)= Count (A1, A4) A1, A4A1, A4 11

= Count (A1, A5)= Count (A1, A5) A1, A5A1, A5 11

AA

11 1010

22 2020

33 3030

44 testtest

55

Examples:Examples:

Page 34: Computing Tools for Engineering Design ( ENME  337 H(3-2))

CountA FunctionCountA Function The next function we will discuss is The next function we will discuss is CountACountA. .

This will return the number of entries This will return the number of entries (actually counts each cell that contains (actually counts each cell that contains number data number data OROR text data) in the selected text data) in the selected range of cells. range of cells.

Blank entries are not Counted. Blank entries are not Counted. Text entries Text entries AREARE Counted. Counted.

Lets use the table here for the discussion that Lets use the table here for the discussion that follows. follows. We will look at several different specific We will look at several different specific examples that show how the CountA examples that show how the CountA functions can be used!functions can be used!

AA

11 1010

22 2020

33 3030

44 testtest

55

Page 35: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Example of Example of CountACountA

Cells to Cells to look atlook at

AnsweAnswerr

= CountA= CountA (A1:A3)(A1:A3) A1, A2, A3A1, A2, A3 33

= CountA (A1:A3, = CountA (A1:A3, 100)100)

A1, A2, A3 and A1, A2, A3 and 100 100

44

= CountA (A1, A3)= CountA (A1, A3) A1, A3A1, A3 22

= CountA (A1, A4)= CountA (A1, A4) A1, A4A1, A4 22

= CountA (A1, A5)= CountA (A1, A5) A1, A5A1, A5 11

AA

11 1010

22 2020

33 3030

44 testtest

55

Examples:Examples:

Page 36: Computing Tools for Engineering Design ( ENME  337 H(3-2))

IF FunctionIF Function The next function we will discuss is The next function we will discuss is

IFIF. The IF function will check the . The IF function will check the logical condition of a statement logical condition of a statement and return one value if true and a and return one value if true and a different value if false. The syntax different value if false. The syntax is is

=IF (condition, value-if-true, value-=IF (condition, value-if-true, value-if-false)if-false)

value returned may be either a value returned may be either a number or text number or text

if value returned is text, it must be if value returned is text, it must be in quotesin quotes

Lets use the table here for the Lets use the table here for the discussion that follows. We discussion that follows. We will look at several different will look at several different specific examples that show specific examples that show how the IF functions can be how the IF functions can be used!used!

A B

1 Price Over a dollar?

2 $.95 No

3 $1.37 Yes

4 comparing #

returning #

5 14000 0.08

6 8453 0.05

Page 37: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Examples:Examples:

Example of IFExample of IFtyped into typed into column Bcolumn B

ComparesCompares AnsweAnswerr

=IF (A2>1,"Yes","No") =IF (A2>1,"Yes","No") is ( .95 > 1) is ( .95 > 1) NoNo

=IF (A3>1, "Yes", "No") =IF (A3>1, "Yes", "No") is (1.37 > 1) is (1.37 > 1) YesYes

=IF =IF (A5>10000, .08, .05) (A5>10000, .08, .05)

is (14000 > is (14000 > 10000)10000)

0.080.08

=IF =IF (A6>10000, .08, .05) (A6>10000, .08, .05)

is (8453 > 10000) is (8453 > 10000) 0.050.05

A B

1 Price Over a dollar?

2 $.95 No

3 $1.37 Yes

4 comparing # returning #

5 14000 0.08

6 8453 0.05

Page 38: Computing Tools for Engineering Design ( ENME  337 H(3-2))

PMT (loan stuff) FunctionPMT (loan stuff) Function

The PMT function returns the periodic (in this case The PMT function returns the periodic (in this case monthly) payment for an annuity (in this case a loan). This monthly) payment for an annuity (in this case a loan). This is the PMT function that was used for the car purchase in is the PMT function that was used for the car purchase in the first example. There are a few things that we must the first example. There are a few things that we must know in order for this function to work. To calculate the know in order for this function to work. To calculate the loan we must know a combination of the following loan we must know a combination of the following

(rate) interest rate per period (rate) interest rate per period (NPER) number of payments until repaid (NPER) number of payments until repaid (PV) present value of the loan (amount we are (PV) present value of the loan (amount we are

borrowing) borrowing) (FV) future value of the money (for saving or (FV) future value of the money (for saving or

investing) investing) (type) enter 0 or 1 to indicate when payments are (type) enter 0 or 1 to indicate when payments are

due. due.

=PMT(rate, NPER, PV, FV, type)

Page 39: Computing Tools for Engineering Design ( ENME  337 H(3-2))

ExamplesExamples::

Equation goes into c7 =PMT(C4/12,C5,-C3)C4 is the yearly interest and since it's compounded monthly we divide by 12C5 is the number of months (# of payments)-C3 is the amount of money we have (borrow - negative)

Note that the rate is per period. If we have an annual interest rate of 9.6% and we are calculating monthly payments, we must divide the annual interest rate by 12 to calculate the monthly interest rate.

Page 40: Computing Tools for Engineering Design ( ENME  337 H(3-2))

SIN COS TAN etc. SIN COS TAN etc. FunctionsFunctions

Excel has most of the math and trig functions built into it. If you Excel has most of the math and trig functions built into it. If you need to use the need to use the SINSIN, , COSCOS, , TANTAN functions, they can be typed functions, they can be typed into any cell. If you wanted to find: into any cell. If you wanted to find:

angle

sin cos tan

REF =sin(REF)

=cos(REF)

=tan(REF)

0 0.000.00 1.001.00 0.000.00

30 0.500.50 0.870.87 0.580.58

45 0.710.71 0.710.71 1.001.00

90 1.001.00 0.000.00

180 0.000.00 -1.00-1.00 0.000.00

format for radians formula = sin (angle) the argument angle is in radians

format for degrees formula = sin (angle * pi()/180) the argument angle is in degrees

To calculate trig functions in degrees you must convert them - otherwise excel will calculate them in radians. You can type in either an actual number for the REF or you can also type in a reference from the excel spreadsheet (like A2).

Page 41: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Function WizardFunction Wizard In Excel there is a help tool for functions called the Function Wizard. There are two ways to get the function wizard. If you look at the

Standard Toolbar, the function wizard icon looks like the icon on the right.

The other way to get to the function wizard is to go to the Menu INSERT -- down to FUNCTION.

Either way you get there, at this point Excel will list all of the functions available. Upon choosing the function, Excel will prompt you for the information it needs to complete the function. Mini descriptions are available for each of the cells. It is often necessary for you to understand the functions in order to be able to figure out these descriptions.

Yeah, I know it would have been nice to know this earlier, but it is important for you to understand how the functions work before you start using the Function Wizard. It is faster to type the basic function in from the keyboard as opposed to going through the steps of this tool.

Well, that is all of the functions we are going to cover.

On to the next phase of the course.

Page 42: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Copying FormulasCopying Formulas Sometimes when we enter a formula, we need to repeat the same Sometimes when we enter a formula, we need to repeat the same

formula for many different cells. In the spreadsheet we can use the formula for many different cells. In the spreadsheet we can use the copy and paste command. The cell locations in the formula are copy and paste command. The cell locations in the formula are pastedpasted relative to the position we relative to the position we CopyCopy them from. them from.

Cells information is copied from its relative position. In other words in the original cell (C1) the equation was (A1+B1). When we paste the function it will look to the two cells to the left. So the equation pasted into (C2) would be (A2+B2). And the equation pasted into (C3) would be (A3+B3).

If you have a lot of duplicate formulas you can also perform what is referred to as a FILL DOWN. (discussed next).

A B C

1 5 3 =A1+B1

2 8 2 =A2+B2

3 4 6 =A3+B3

4 3 8 =? + ?

Page 43: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Fill DownFill DownOften we have several cells that need the same formula (in Often we have several cells that need the same formula (in

relationship) to the location it is to be typed into. There is a relationship) to the location it is to be typed into. There is a short cut that is called Fill Down. There are a number of short cut that is called Fill Down. There are a number of ways to perform this operation. One of the ways is to ways to perform this operation. One of the ways is to 1.1. select the cell that has the original formula select the cell that has the original formula 2.2. hold the shift key down and click on the last cell (in the hold the shift key down and click on the last cell (in the

series that needs the formula) series that needs the formula) 3.3. under the under the editedit menu go down to menu go down to fillfill and over to and over to downdown

Cells information is copied from its relative position. In other words in the original cell (C1) the equation was (A1+B1). When we paste the function it will look to the two cells to the left. So the equation pasted into (C2) would be (A2+B2). And the equation pasted into (C3) would be (A3+B3). And the equation pasted into (C4) would be(A4+B4).

A B C

1 5 3 =A1+B1

2 8 2 fill down

3 4 6 fill down

4 3 8 fill down

Page 44: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Absolute PositioningAbsolute PositioningSometimes it is necessary to keep a certain position that is

not relative to the new cell location. This is possible by inserting a $ before the Column letter or a $ before the Row number (or both). This is called Absolute Positioning.

If we were to fill down with this formula we would have the exact same formula in all of the cells C1, C2, C3, and C4. The dollar signs Lock the cell location to a FIXED position. When it is copied and pasted it remains EXACTLY the same (no relative).

A B C

1 5 3 =$A$1+$B$1

2 8 2 =$A$1+$B$1

3 4 6 =$A$1+$B$1

4 3 8 =$A$1+$B$1

Page 45: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Fill RightFill RightWe can also fill right. We must select the original cell (and the

cells to the right) and select from the Edit menu -- Fill and Right.

If we were to fill right from A1 to C1 we would get the formulas displayed to the left. Notice that the second part of the equation is FIXED or (ABSOLUTE REFERENCE so always references B3 which is 10).

A B C

1 =A2+$B$3

=B2+$B$3

=C2+$B$3

2 6 2 5

3 7 10 4

4 9 8 7

Page 46: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Formatting Formatting

Page 47: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Formatting TextFormatting Text Spreadsheets can be pretty dry, so we need some tools to dress Spreadsheets can be pretty dry, so we need some tools to dress

them up a little. We can use most of the tricks in our word processor them up a little. We can use most of the tricks in our word processor to do the formatting of text. We can use : bold face, italics, to do the formatting of text. We can use : bold face, italics, underline, change the color, align (left, right, center), font size, font, underline, change the color, align (left, right, center), font size, font, etc.etc.

We need to We need to selectselect the the cell (or group of cells)cell (or group of cells) that we wish to change that we wish to change the formatting and then the formatting and then go from the FORMAT go from the FORMAT menu -- down to CELLS -- menu -- down to CELLS -- click on FONT. Here is a click on FONT. Here is a picture of what you will picture of what you will see there. Notice that you see there. Notice that you can choose to change the can choose to change the alignment as well as alignment as well as several other options.several other options.

Page 48: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Formatting NumbersFormatting Numbers We often need to format the numbers to display the appropriate We often need to format the numbers to display the appropriate

number of decimals, dollar signs, percentage, red (for negative number of decimals, dollar signs, percentage, red (for negative dollars), etc. It is best to keep numbers describing similar items as dollars), etc. It is best to keep numbers describing similar items as uniform as possible.uniform as possible.

Example:Example: If we have the number If we have the number 3.532626246724233.53262624672423, we would probably have , we would probably have

to make the column wider and at the least bore most people. We to make the column wider and at the least bore most people. We need to set the number of decimal places to what is important. If need to set the number of decimal places to what is important. If this was a dollar figure that had calculated tax it should be this was a dollar figure that had calculated tax it should be $3.53$3.53. .

Here is a screen displaying Here is a screen displaying what you would see if you what you would see if you select a select a cell (or group of cell (or group of cells)cells) and from the FORMAT and from the FORMAT menu -- go down to format menu -- go down to format -- click on number. -- click on number.

Page 49: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Column WidthColumn Width A question that everyone (who has ever worked on a spreadsheet) has A question that everyone (who has ever worked on a spreadsheet) has

asked at one time or another is, "Where did all my numbers go?" or asked at one time or another is, "Where did all my numbers go?" or same question, "Where did all of those ####### come from and same question, "Where did all of those ####### come from and why are they in my spreadsheet?" why are they in my spreadsheet?" The problem is the number trying to be displayed in a particular cell The problem is the number trying to be displayed in a particular cell does not have enough width to display properly. To clear up the does not have enough width to display properly. To clear up the problem we just need to make the column wider. You can do this problem we just need to make the column wider. You can do this many ways.many ways.

Here are two ways to change the column width:

1. Select the column (or columns) with the problem by clicking on their labels (letters). Then you choose the MENU FORMAT. Go down to COLUMN and over to WIDTH and type in a new number for the column width.

2. Move the arrow to the right side of the column label and click and drag the mouse to the right (to make wider) or left (to make smaller). Let up on the mouse button when the column is wide enough.

Notice the cursor changes to a vertical line with arrows pointing left and right.

In many spreadsheets you can also change the vertical height of a row by moving the lower edge of the row title (number).

Page 50: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Inserting A ColumnInserting A Column Sometimes we (all) make mistakes or things change. If you Sometimes we (all) make mistakes or things change. If you

have a spreadsheet designed and you forgot to include some have a spreadsheet designed and you forgot to include some important information, you can insert a column into an important information, you can insert a column into an existing spreadsheet. What you must do is click on the column existing spreadsheet. What you must do is click on the column label (letter) and choose in label (letter) and choose in ColumnsColumns from the from the InsertInsert menu. menu. This will insert a column This will insert a column immediately leftimmediately left of the selected of the selected column.column.

As you can see from this example there was a blank column inserted into the spreadsheet. You might wonder if this will affect your referenced formulas. Yes, the Referenced cells are changed to their new locations. For example:Cell C4 was =C3+B4and now is =D3+B4

Page 51: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Inserting A RowInserting A Row Likewise, we can also insert rows. With the row label (number) Likewise, we can also insert rows. With the row label (number)

selected you must choose the selected you must choose the RowRow from the from the InsertInsert menu. menu. Again this will insert a row Again this will insert a row beforebefore the row you have selected. the row you have selected.

The formulas will be updated to their corresponding locations.

C3 was = C2+B3NOW C4=C2+B4

Page 52: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Charts or GraphingCharts or Graphing Numbers can usually be represented quicker and to a larger audience Numbers can usually be represented quicker and to a larger audience

in a picture format. Excel has a chart program built into its main in a picture format. Excel has a chart program built into its main program.program.

The Chart Wizard will step you through questions that will The Chart Wizard will step you through questions that will (basically) draw the chart from the data that you have (basically) draw the chart from the data that you have selectedselected. . There are many types of charts. The two most widely used are the bar There are many types of charts. The two most widely used are the bar chart and the pie chart.chart and the pie chart.

The BAR Chart is usually used to display a change (growth or decline) over a time period. You can quickly compare the numbers of two different bar charts to each other.

The PIE Chart is usually used to look at what makes up a whole Something. If you had a pie chart of where you spent your money you could look at the percentages of dollars spent on food (or any other category).

You can add legends, titles, and change many of the display variables.

Page 53: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Next topic:Next topic:

Microsoft ExcelMicrosoft Excel and Visual and Visual basic (VBA)basic (VBA)

How to create programs in Excel using Macros and VB to solve diverse engineering problems in Heat

Transfer, Numerical Methods, Fluid Mechanics, etc.

http://www.mindspring.com/~tflynn/excelvba.html

Page 54: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Excel VBA Programming For Excel VBA Programming For DummiesDummies

DetailsDetails AuthorAuthor:: John Walkenbach John Walkenbach ISBNISBN:: 0-7645-7412-4 0-7645-7412-4 PublisherPublisher:: Wiley, 2004, 390 pp., List price Wiley, 2004, 390 pp., List price

$24.99 (US) $24.99 (US)

Target ReaderTarget Reader: : This book is intended for This book is intended for experienced Excel users who want to learn experienced Excel users who want to learn the basics of VBA programming. It's good for the basics of VBA programming. It's good for Excel 2000, 2002, and 2003.Excel 2000, 2002, and 2003.

CommentsComments:: This is a light-hearted guide to This is a light-hearted guide to learning VBA programming. Despite the title, learning VBA programming. Despite the title, you'll find lots of useful information, tips, and you'll find lots of useful information, tips, and techniques. The book doesn't have a CD, but techniques. The book doesn't have a CD, but the sample files are available to download the sample files are available to download from the Web.from the Web.

Page 55: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Excel VBA Programming For Excel VBA Programming For DummiesDummies

Table of ContentsTable of Contents

Part I: Part I: Introducing VBA Part II: Part II: How VBA Works With Excel Part III: Part III: Programming Concepts Part IV: Part IV: Developing Custom Dialog Boxes Part V: Part V: Creating Custom Menus and Toolbars Part VI: Part VI: Putting It All Together Part VII: Part VII: The Part of Tens

Page 56: Computing Tools for Engineering Design ( ENME  337 H(3-2))

Spreadsheet Spreadsheet ProgrammingProgramming

Just as the early programming languages were designed to generate spreadsheet printouts, programming techniques themselves have evolved to process tables (= spreadsheets = matrices) of data more efficiently in the computer itself. A spreadsheet program is designed to perform general computation tasks using spatial relationships rather than time as the primary organizing principle. Many programs designed to perform general computation use timing, the ordering of computational steps, as their primary way to organize a program. A well defined entry point is used to determine the first instructions, and all other instructions must be reachable from that point.In a spreadsheet, however, a set of cells is defined, with a spatial relation to one another. In the earliest spreadsheets, these arrangements were a simple two-dimensional grid. Over time, the model has been expanded to include a third dimension, and in some cases a series of named grids. The most advanced examples allow inversion and rotation operations which can slice and project the data set in various ways.The cells are functionally equivalent to variables in a sequential programming model. Cells often have a formula, a set of instructions which can be used to compute the value of a cell. Formulas can use the contents of other cells or external variables such as the current date and time. It is often convenient to think of a spreadsheet as a mathematical graph, where the nodes are spreadsheet cells, and the edges are references to other cells specified in formulas. This is often called the dependency graph of the spreadsheet. References between cells can take advantage of spatial concepts such as relative position and absolute position, as well as named locations, to make the spreadsheet formulas easier to understand and manage.Spreadsheets usually attempt to automatically update cells when the cells on which they depend have been changed. The earliest spreadsheets used simple tactics like evaluating cells in a particular order, but modern spreadsheets compute a minimal recomputation order from the dependency graph. Later spreadsheets also include a limited ability to propagate values in reverse, altering source values so that a particular answer is reached in a certain cell. Since spreadsheet cells formulas are not generally invertible, though, this technique is of somewhat limited value.Many of the concepts common to sequential programming models have analogues in the spreadsheet world. For example, the sequential model of the indexed loop is usually represented as a table of cells, with similar formulas. Cyclic dependency graphs produce the traditional construct known as the infinite loop. Most spreadsheets allow iterative recalculation in the presence of these cyclic dependencies, which can be either directly controlled by a user or which stop when threshold conditions are reached.The power of spreadsheets derives largely from the fact that human beings have a well developed intuition about spaces and a well developed notion of dependency between items. Thus, many people find it easier to perform complex calculations in a spreadsheet than writing the equivalent sequential program.