SlideShare una empresa de Scribd logo
1 de 7
Chapter 2
Excel Fundamentals
Logical IF Statements, Lookup
Tables, Linear Interpolation
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The IF Statement
• Logical statements are used to control the
sequence of computations in programs and in
spreadsheet
• MATLAB and Excel both contain IF statements for
adding logical control
• An IF statement tests a condition, and the flow of
calculations is dependent on whether the
condition is true or false
• This is best illustrated with a simple example
Logical Test Example
• Consider taking the absolute value of a number
• How would you instruct Excel to perform this
function (without using the built-in function ABS)
• There are ways to accomplish this without an IF
statement (for example, you can square the
number and then take its square root, which
always returns the positive root), but the most
straightforward method is to use a logical test
Engineering Computation: An Introduction Using MATLAB and Excel
Logical Test Example (cont.)
• In words, you might describe your procedure as:
“If the number is less then zero, then take the negative of
that number, else leave the number as it is”
• This if-then-else logic is widely used in
programming, and can also be used in Excel
• Format of Excel IF statement:
-if(logical_test,value_if_true,value_if_false)
Engineering Computation: An Introduction Using MATLAB and Excel
Excel IF Statement
• The IF statement is a function, with three arguments
• The first argument is the logical test (the condition).
For our example, the logical test will be that the value
of the number considered is less than zero
• The second argument is the action to be taken if the
condition is true (take the negative of the number)
• The third argument is the action to be taken if the
condition is false (report the input number
unchanged)
Engineering Computation: An Introduction Using MATLAB and Excel
Absolute Value Example
• The number to be evaluated is entered into cell A1
• The formula is entered into cell B1
Engineering Computation: An Introduction Using MATLAB and Excel
Nesting IF Statements
• Often, there will be more than two possible outputs for a given
input
• In MATLAB, we use the if-then-else function
• In Excel, we must nest IF statements
• Consider this example: we want to read in a numerical grade and
convert it to a letter grade on a scale of:
– Greater than or equal to 90 = A,
– Greater than or equal to 80 and less than 90 = B
– Greater than or equal to 70 and less than 80 = C
– Greater than or equal to 60 and less than 70 = D
– Less than or equal to 60 = F
Engineering Computation: An Introduction Using MATLAB and Excel

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Microsoft Excel Basics
Microsoft Excel BasicsMicrosoft Excel Basics
Microsoft Excel Basics
 
Intro to Excel Basics: Part I
Intro to Excel Basics: Part IIntro to Excel Basics: Part I
Intro to Excel Basics: Part I
 
Advanced Microsoft Excel
Advanced Microsoft ExcelAdvanced Microsoft Excel
Advanced Microsoft Excel
 
Functions and formulas of ms excel
Functions and formulas of ms excelFunctions and formulas of ms excel
Functions and formulas of ms excel
 
MS Excel
MS ExcelMS Excel
MS Excel
 
Basic Excel PPT Presentation.pptx
Basic Excel PPT Presentation.pptxBasic Excel PPT Presentation.pptx
Basic Excel PPT Presentation.pptx
 
Microsoft Word 2010 Beginning Class
Microsoft Word 2010 Beginning ClassMicrosoft Word 2010 Beginning Class
Microsoft Word 2010 Beginning Class
 
Excel training
Excel trainingExcel training
Excel training
 
Excel functions and formulas
Excel functions and formulasExcel functions and formulas
Excel functions and formulas
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
 
Learning power point 2016
Learning power point 2016Learning power point 2016
Learning power point 2016
 
Presentation
PresentationPresentation
Presentation
 
Ms excel ppt
Ms excel pptMs excel ppt
Ms excel ppt
 
Advance excel
Advance excelAdvance excel
Advance excel
 
Ms Excel Basic to Advance Tutorial
Ms Excel Basic to Advance TutorialMs Excel Basic to Advance Tutorial
Ms Excel Basic to Advance Tutorial
 
Training On Microsoft Excel
Training On Microsoft ExcelTraining On Microsoft Excel
Training On Microsoft Excel
 
01 Excel interface
01 Excel interface01 Excel interface
01 Excel interface
 
MS Word Basics
MS Word BasicsMS Word Basics
MS Word Basics
 
Charts in EXCEL
Charts in EXCELCharts in EXCEL
Charts in EXCEL
 
MS ACCESS (REPORT)
MS ACCESS (REPORT)MS ACCESS (REPORT)
MS ACCESS (REPORT)
 

Similar a Excel IF function

Engineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfEngineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfssuseraae901
 
The 4 Step Excel 2013 Functions Guide
The 4 Step Excel 2013 Functions GuideThe 4 Step Excel 2013 Functions Guide
The 4 Step Excel 2013 Functions GuideHow To Technology
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and reviewAbdullah Al-hazmy
 
Libre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding FunctionsLibre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding FunctionsSmart Chicago Collaborative
 
presentationMs excel
presentationMs excelpresentationMs excel
presentationMs excelTanveer Ahmed
 
Excel basics for everyday use-the more advanced stuff
Excel basics for everyday use-the more advanced stuffExcel basics for everyday use-the more advanced stuff
Excel basics for everyday use-the more advanced stuffKevin McLogan
 
10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any JobHitesh Biyani
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and SelectionAhmed Nobi
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithmlilyMalar1
 
Excel basics for everyday use part three
Excel basics for everyday use part threeExcel basics for everyday use part three
Excel basics for everyday use part threeKevin McLogan
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexityAnaya Zafar
 
excel ppt
excel pptexcel ppt
excel pptdd
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptxAlgorithms and problem solving.pptx
Algorithms and problem solving.pptxaikomo1
 
Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Blue Elephant Consulting
 
Matlab ch1 (1)
Matlab ch1 (1)Matlab ch1 (1)
Matlab ch1 (1)mohsinggg
 

Similar a Excel IF function (20)

bisection method
bisection methodbisection method
bisection method
 
Mbd dd
Mbd ddMbd dd
Mbd dd
 
Engineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfEngineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdf
 
The 4 Step Excel 2013 Functions Guide
The 4 Step Excel 2013 Functions GuideThe 4 Step Excel 2013 Functions Guide
The 4 Step Excel 2013 Functions Guide
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 
Libre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding FunctionsLibre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding Functions
 
presentationMs excel
presentationMs excelpresentationMs excel
presentationMs excel
 
Excel basics for everyday use-the more advanced stuff
Excel basics for everyday use-the more advanced stuffExcel basics for everyday use-the more advanced stuff
Excel basics for everyday use-the more advanced stuff
 
10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Excel basics for everyday use part three
Excel basics for everyday use part threeExcel basics for everyday use part three
Excel basics for everyday use part three
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
excel ppt
excel pptexcel ppt
excel ppt
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptxAlgorithms and problem solving.pptx
Algorithms and problem solving.pptx
 
3.pdf
3.pdf3.pdf
3.pdf
 
Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1
 
Data structure
Data structureData structure
Data structure
 
Matlab ch1 (1)
Matlab ch1 (1)Matlab ch1 (1)
Matlab ch1 (1)
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 

Excel IF function

  • 1. Chapter 2 Excel Fundamentals Logical IF Statements, Lookup Tables, Linear Interpolation Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
  • 2. The IF Statement • Logical statements are used to control the sequence of computations in programs and in spreadsheet • MATLAB and Excel both contain IF statements for adding logical control • An IF statement tests a condition, and the flow of calculations is dependent on whether the condition is true or false • This is best illustrated with a simple example
  • 3. Logical Test Example • Consider taking the absolute value of a number • How would you instruct Excel to perform this function (without using the built-in function ABS) • There are ways to accomplish this without an IF statement (for example, you can square the number and then take its square root, which always returns the positive root), but the most straightforward method is to use a logical test Engineering Computation: An Introduction Using MATLAB and Excel
  • 4. Logical Test Example (cont.) • In words, you might describe your procedure as: “If the number is less then zero, then take the negative of that number, else leave the number as it is” • This if-then-else logic is widely used in programming, and can also be used in Excel • Format of Excel IF statement: -if(logical_test,value_if_true,value_if_false) Engineering Computation: An Introduction Using MATLAB and Excel
  • 5. Excel IF Statement • The IF statement is a function, with three arguments • The first argument is the logical test (the condition). For our example, the logical test will be that the value of the number considered is less than zero • The second argument is the action to be taken if the condition is true (take the negative of the number) • The third argument is the action to be taken if the condition is false (report the input number unchanged) Engineering Computation: An Introduction Using MATLAB and Excel
  • 6. Absolute Value Example • The number to be evaluated is entered into cell A1 • The formula is entered into cell B1 Engineering Computation: An Introduction Using MATLAB and Excel
  • 7. Nesting IF Statements • Often, there will be more than two possible outputs for a given input • In MATLAB, we use the if-then-else function • In Excel, we must nest IF statements • Consider this example: we want to read in a numerical grade and convert it to a letter grade on a scale of: – Greater than or equal to 90 = A, – Greater than or equal to 80 and less than 90 = B – Greater than or equal to 70 and less than 80 = C – Greater than or equal to 60 and less than 70 = D – Less than or equal to 60 = F Engineering Computation: An Introduction Using MATLAB and Excel