SlideShare una empresa de Scribd logo
1 de 10
Descargar para leer sin conexión
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 1
 IF ทำหน้ำที่เลือกใช ้สูตรคำนวณได ้2 แบบ ขึ้นอยู่กับเงื่อนไขว่ำจริงหรือเท็จ?
– ถ ้ำเงื่อนไขเป็นจริง (TRUE) จะทำกำรคำนวณด ้วย สูตรแบบหนึ่ง
– ถ ้ำเงื่อนไขเป็นเท็จ (FALSE) จะคำนวณด ้วย สูตรอีกแบบหนึ่ง
1
เงื่อนไข
สูตรเมื่อเงื่อนไข
TRUE
สูตรเมื่อเงื่อนไข
FALSE
ที่ใช ้คำว่ำสูตร เพรำะใส่สูตรยำวๆ
ได ้จริงๆ ซับซ ้อนแค่ไหนก็ได ้
ไม่ใช่ใส่ได ้แค่ค่ำธรรมดำๆ
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 2
 IF มีวิธีเขียนสูตรว่ำ
=IF(logical_test, [value_if_true], [value_if_false]) หรือ
=IF(เงื่อนไข,สูตรที่จะใช ้เมื่อเงื่อนไขจริง,สูตรที่จะใช ้เมื่อเงื่อนไขเท็จ)
 กำรที่เงื่อนไขจะเป็น TRUE/FALSE ได ้ต ้องมีเครื่องหมำยเปรียบเทียบ เช่น =,>,<,<>,>=,<=
 เช่น อยำกให ้ค่ำ Commission 5% กรณียอดขำยใน A1 มำกกว่ำ 1000 บำทเท่ำนั้น
 หำกช่อง A1>1000 จริง ให ้เอำค่ำ A1*5% , ถ ้ำไม่จริง ให ้แสดงค่ำ “Not Pass” ต ้องเขียนว่ำ
 =IF(A1>1000,A1*5%,“Not Pass”)
2
สูตรที่ทำให ้ผลลัพธ์
ออกมำเป็น
TRUE/FALSE
เท่ำนั้น
สูตรอะไรก็ได ้ 1
(แต่ไม่ต ้องใส่
เครื่องหมำย = แล ้ว)
สูตรอะไรก็ได ้ 2
(แต่ไม่ต ้องใส่
เครื่องหมำย = แล ้ว)
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 3
 =IF(logical_test, [value_if_true], [value_if_false])
 ในช่องเงื่อนไข นอกจำกจะใช ้TRUE กับ FALSE ได ้แล ้ว ยังใช ้ตัวเลขแทน
ได ้ด ้วย
– IF จะตีควำมเลข 0 เป็น FALSE ส่วนเลขอื่นๆ เป็น TRUE
 ถ ้ำดูดีๆจะเห็นว่ำ [value_if_true], [value_if_false] เป็นค่ำ Optional
หำกเรำไม่ระบุอะไรลงไป …
– กรณีจริงมันจะออกมำเป็นคำว่ำ TRUE
– กรณีเท็จมันจะออกมำเป็นคำว่ำ FALSE
 เช่น =IF(A1=“M”,“Male”) คือไม่ได ้ใส่ตรง FALSE ว่ำให ้เป็นอะไร
– หำก A1 มีค่ำเป็นข ้อควำมว่ำ M จะให ้ค่ำเป็นข ้อควำม Male
– แต่ถ ้ำมีค่ำอื่นๆ(เป็นเท็จ) จะได ้ผลเป็นคำว่ำ FALSE ออกมำเลยครับ
– ที่ต ้องใส่ “ ” ครอบ M หรือ Male เพื่อบอกว่ำเป็น Text ไม่ใช่ Defined Name
3
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 4
 หำกต ้องกำรเช็ค TRUE/FALSE เฉยๆ ไม่ต ้องใช ้IF ก็ได ้นะ...
– เช่น อยำกรู้ว่ำ A1>1000 รึเปล่ำ?
– สำมำรถใส่สูตรว่ำ =A1>1000 ได ้เลย
– ผลลัพธ์จะออกมำเป็น TRUE/FALSE ให ้ทันที!!
– พูดง่ำยๆว่ำไม่ต ้องเขียน =IF(A1>1000,TRUE,FALSE) เลย
4
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 5
 ตรงส่วนเงื่อนไข อย่ำงที่บอกว่ำทำยังไงก็ได ้ให ้ออกมำเป็น TRUE/FALSE ดังนั้น จึงใช ้
ร่วมกับฟังก์ชั่นตรรกศำสตร์ได ้เช่น AND, OR, NOT
 จะเชื่อมด ้วยตัวใดตัวหนึ่ง เช่น
– =IF(logical_test, [value_if_true], [value_if_false])
– =IF(AND(เงื่อนไข1,เงื่อนไข2), [value_if_true], [value_if_false])
– =IF(OR(เงื่อนไข1,เงื่อนไข2), [value_if_true], [value_if_false])
 หรือจะเชื่อมหลำยตัวพร ้อมกันก็ได ้
– =IF(AND(เงื่อนไข1,OR(เงื่อนไข2,เงื่อนไข3)), [value_if_true], [value_if_false])
5
ผลสรุป
เงื่อนไข
สูตรเมื่อเงื่อนไข
TRUE
สูตรเมื่อเงื่อนไข
FALSE
เงื่อนไข 1
เงื่อนไข 2
เงื่อนไข 3
เงื่อนไข 4
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 6
 นิเสธ แทนด ้วย ฟังก์ชั่น NOT : กลับจริงเป็นเท็จ เท็จเป็นจริง
 และ แทนด ้วย ฟังก์ชั่น AND : ถ ้ำเงื่อนไข Input ทุกอันเป็นจริง จะได ้ค่ำออกมำเป็นจริง กรณีอื่น
จะเป็นเท็จ ตรงกับภำษำพูดว่ำ “และ”
 หรือ แทนด ้วย ฟังก์ชั่น OR : ถ ้ำอย่ำงน้อยเงื่อนไขใดเงื่อนไขหนึ่งจริง จะได ้ค่ำออกมำเป็นจริง
(ต ้องเท็จทุกอันจึงจะออกมำเป็นเท็จ) คล ้ำยกับภำษำพูดว่ำ “หรือ”
6
เงื่อนไข NOT(เงื่อนไข)
TRUE FALSE
FALSE TRUE
เงื่อนไข1 เงื่อนไข2 AND(เงื่อนไข1,เงื่อนไข2)
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE FALSE
FALSE FALSE FALSE
เงื่อนไข1 เงื่อนไข2 AND(เงื่อนไข1,เงื่อนไข2)
TRUE TRUE TRUE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 7
 IF 1 ตัว สำมำรถแตกกิ่งก ้ำนสำขำกำรตัดสินใจ (Decision Tree) ได ้2 กิ่ง
– นั่นคือ กำรใช ้IF 1 ตัว จะมีผลลัพธ์ได ้ 2 อย่ำง คือ TRUE และ FALSE
 ถ ้ำต ้องกำรให ้มีผลลัพธ์ที่มำกกว่ำ 2 อย่ำง ต ้องเอำ IF หลำยตัวมำซ ้อนกัน
 ในแต่ละกิ่ง ที่ จริง /เท็จ เรำสำมำรถเลือกที่จะใส่ IF ซ ้อนลงไปอีกหรือไม่ก็ได ้
 ในสูตร จำนวนวงเล็บเปิดต ้องเท่ำกับวงเล็บปิดเสมอ
7
เงื่อนไข 1
TRUE1
เงื่อนไข 2
TRUE2
FALSE2
เงื่อนไข 1
เงื่อนไข 2
TRUE2
FALSE2
เงื่อนไข 3
TRUE3
FALSE3
แตกที่ผลลัพธ์ FALSE อย่ำงเดียว แตกที่ผลลัพธ์ทั้ง TRUE และ FALSE
=IF(เงื่อนไข1,TRUE1,IF(เงื่อนไข2,TRUE2,FALSE2))
=IF(เงื่อนไข1,IF(เงื่อนไข2,TRUE2,FALSE2),IF(เงื่อนไข
3,TRUE3,FALSE3))
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 8
 หากนึกถึงคาว่า “ถ้า หาก กรณี ฯลฯ” ให้นึกถึง IF
 IF 1 ตัว สามารถแตกกิ่งก้านการตัดสินใจ (Decision Tree) ได้ 2 กิ่ง
– ถ ้ำเงื่อนไขเป็นจริง (TRUE) จะทำกำรคำนวณด ้วย สูตรแบบหนึ่ง
– ถ ้ำเงื่อนไขเป็นเท็จ (FALSE) จะคำนวณด ้วย สูตรอีกแบบหนึ่ง
 ถ้าต้องการให้มีผลลัพธ์การตัดสินใจที่มากกว่า 2 อย่าง ต้องเอา IF
หลายตัวมาซ้อนกัน
– ในแต่ละกิ่ง ที่ จริง /เท็จ เรำสำมำรถเลือกที่จะใส่ IF ซ ้อนลงไปอีกหรือไม่ก็ได ้
– ในสูตร จำนวนวงเล็บเปิดต ้องเท่ำกับวงเล็บปิดเสมอ
 ส่วนเงื่อนไขใช้ร่วมกับฟังก์ชั่นตรรกศาสตร์ได้ ซับซ้อนแค่ไหนก็ได้
– ให ้ผลลัพธ์สุดท ้ำยออกมำเป็น TRUE/FALSE
– ฟังก์ชั่นตรรกศำสตร์ เช่น AND, OR, NOT
8
inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 9
 ถ ้ำมีสินค ้ำให ้ลูกค ้ำเลือก 2 ชิ้น จำกสินค ้ำ 4 ชิ้น คือ ก ข ค ง
 หำกลูกค ้ำเลือก ก หรือ ค แต่ห ้ำมเลือกทั้ง ก และ ค พร ้อมกัน เรำจะให ้ตัง
1000 บำท กรณีอื่นๆ (รวมถึงเลือก ก และ ค พร ้อมกัน) จะได ้ตัง 500 บำท
 สมมติช่อง B1 คือสินค ้ำชิ้นที่ 1, B2 คือ สินค ้ำชิ้นที่ 2
 หำกต ้องกำรแสดงเงินรำงวัลที่จะได ้ใน B4 ต ้องเขียนสูตรว่ำอะไร?
9

Más contenido relacionado

Destacado

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Destacado (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Excel 9 หน้า : IF ถ้ารู้งี้ ก็เก่งไปนานแล้ว!

  • 1.
  • 2. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 1  IF ทำหน้ำที่เลือกใช ้สูตรคำนวณได ้2 แบบ ขึ้นอยู่กับเงื่อนไขว่ำจริงหรือเท็จ? – ถ ้ำเงื่อนไขเป็นจริง (TRUE) จะทำกำรคำนวณด ้วย สูตรแบบหนึ่ง – ถ ้ำเงื่อนไขเป็นเท็จ (FALSE) จะคำนวณด ้วย สูตรอีกแบบหนึ่ง 1 เงื่อนไข สูตรเมื่อเงื่อนไข TRUE สูตรเมื่อเงื่อนไข FALSE ที่ใช ้คำว่ำสูตร เพรำะใส่สูตรยำวๆ ได ้จริงๆ ซับซ ้อนแค่ไหนก็ได ้ ไม่ใช่ใส่ได ้แค่ค่ำธรรมดำๆ
  • 3. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 2  IF มีวิธีเขียนสูตรว่ำ =IF(logical_test, [value_if_true], [value_if_false]) หรือ =IF(เงื่อนไข,สูตรที่จะใช ้เมื่อเงื่อนไขจริง,สูตรที่จะใช ้เมื่อเงื่อนไขเท็จ)  กำรที่เงื่อนไขจะเป็น TRUE/FALSE ได ้ต ้องมีเครื่องหมำยเปรียบเทียบ เช่น =,>,<,<>,>=,<=  เช่น อยำกให ้ค่ำ Commission 5% กรณียอดขำยใน A1 มำกกว่ำ 1000 บำทเท่ำนั้น  หำกช่อง A1>1000 จริง ให ้เอำค่ำ A1*5% , ถ ้ำไม่จริง ให ้แสดงค่ำ “Not Pass” ต ้องเขียนว่ำ  =IF(A1>1000,A1*5%,“Not Pass”) 2 สูตรที่ทำให ้ผลลัพธ์ ออกมำเป็น TRUE/FALSE เท่ำนั้น สูตรอะไรก็ได ้ 1 (แต่ไม่ต ้องใส่ เครื่องหมำย = แล ้ว) สูตรอะไรก็ได ้ 2 (แต่ไม่ต ้องใส่ เครื่องหมำย = แล ้ว)
  • 4. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 3  =IF(logical_test, [value_if_true], [value_if_false])  ในช่องเงื่อนไข นอกจำกจะใช ้TRUE กับ FALSE ได ้แล ้ว ยังใช ้ตัวเลขแทน ได ้ด ้วย – IF จะตีควำมเลข 0 เป็น FALSE ส่วนเลขอื่นๆ เป็น TRUE  ถ ้ำดูดีๆจะเห็นว่ำ [value_if_true], [value_if_false] เป็นค่ำ Optional หำกเรำไม่ระบุอะไรลงไป … – กรณีจริงมันจะออกมำเป็นคำว่ำ TRUE – กรณีเท็จมันจะออกมำเป็นคำว่ำ FALSE  เช่น =IF(A1=“M”,“Male”) คือไม่ได ้ใส่ตรง FALSE ว่ำให ้เป็นอะไร – หำก A1 มีค่ำเป็นข ้อควำมว่ำ M จะให ้ค่ำเป็นข ้อควำม Male – แต่ถ ้ำมีค่ำอื่นๆ(เป็นเท็จ) จะได ้ผลเป็นคำว่ำ FALSE ออกมำเลยครับ – ที่ต ้องใส่ “ ” ครอบ M หรือ Male เพื่อบอกว่ำเป็น Text ไม่ใช่ Defined Name 3
  • 5. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 4  หำกต ้องกำรเช็ค TRUE/FALSE เฉยๆ ไม่ต ้องใช ้IF ก็ได ้นะ... – เช่น อยำกรู้ว่ำ A1>1000 รึเปล่ำ? – สำมำรถใส่สูตรว่ำ =A1>1000 ได ้เลย – ผลลัพธ์จะออกมำเป็น TRUE/FALSE ให ้ทันที!! – พูดง่ำยๆว่ำไม่ต ้องเขียน =IF(A1>1000,TRUE,FALSE) เลย 4
  • 6. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 5  ตรงส่วนเงื่อนไข อย่ำงที่บอกว่ำทำยังไงก็ได ้ให ้ออกมำเป็น TRUE/FALSE ดังนั้น จึงใช ้ ร่วมกับฟังก์ชั่นตรรกศำสตร์ได ้เช่น AND, OR, NOT  จะเชื่อมด ้วยตัวใดตัวหนึ่ง เช่น – =IF(logical_test, [value_if_true], [value_if_false]) – =IF(AND(เงื่อนไข1,เงื่อนไข2), [value_if_true], [value_if_false]) – =IF(OR(เงื่อนไข1,เงื่อนไข2), [value_if_true], [value_if_false])  หรือจะเชื่อมหลำยตัวพร ้อมกันก็ได ้ – =IF(AND(เงื่อนไข1,OR(เงื่อนไข2,เงื่อนไข3)), [value_if_true], [value_if_false]) 5 ผลสรุป เงื่อนไข สูตรเมื่อเงื่อนไข TRUE สูตรเมื่อเงื่อนไข FALSE เงื่อนไข 1 เงื่อนไข 2 เงื่อนไข 3 เงื่อนไข 4
  • 7. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 6  นิเสธ แทนด ้วย ฟังก์ชั่น NOT : กลับจริงเป็นเท็จ เท็จเป็นจริง  และ แทนด ้วย ฟังก์ชั่น AND : ถ ้ำเงื่อนไข Input ทุกอันเป็นจริง จะได ้ค่ำออกมำเป็นจริง กรณีอื่น จะเป็นเท็จ ตรงกับภำษำพูดว่ำ “และ”  หรือ แทนด ้วย ฟังก์ชั่น OR : ถ ้ำอย่ำงน้อยเงื่อนไขใดเงื่อนไขหนึ่งจริง จะได ้ค่ำออกมำเป็นจริง (ต ้องเท็จทุกอันจึงจะออกมำเป็นเท็จ) คล ้ำยกับภำษำพูดว่ำ “หรือ” 6 เงื่อนไข NOT(เงื่อนไข) TRUE FALSE FALSE TRUE เงื่อนไข1 เงื่อนไข2 AND(เงื่อนไข1,เงื่อนไข2) TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE เงื่อนไข1 เงื่อนไข2 AND(เงื่อนไข1,เงื่อนไข2) TRUE TRUE TRUE TRUE FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE
  • 8. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 7  IF 1 ตัว สำมำรถแตกกิ่งก ้ำนสำขำกำรตัดสินใจ (Decision Tree) ได ้2 กิ่ง – นั่นคือ กำรใช ้IF 1 ตัว จะมีผลลัพธ์ได ้ 2 อย่ำง คือ TRUE และ FALSE  ถ ้ำต ้องกำรให ้มีผลลัพธ์ที่มำกกว่ำ 2 อย่ำง ต ้องเอำ IF หลำยตัวมำซ ้อนกัน  ในแต่ละกิ่ง ที่ จริง /เท็จ เรำสำมำรถเลือกที่จะใส่ IF ซ ้อนลงไปอีกหรือไม่ก็ได ้  ในสูตร จำนวนวงเล็บเปิดต ้องเท่ำกับวงเล็บปิดเสมอ 7 เงื่อนไข 1 TRUE1 เงื่อนไข 2 TRUE2 FALSE2 เงื่อนไข 1 เงื่อนไข 2 TRUE2 FALSE2 เงื่อนไข 3 TRUE3 FALSE3 แตกที่ผลลัพธ์ FALSE อย่ำงเดียว แตกที่ผลลัพธ์ทั้ง TRUE และ FALSE =IF(เงื่อนไข1,TRUE1,IF(เงื่อนไข2,TRUE2,FALSE2)) =IF(เงื่อนไข1,IF(เงื่อนไข2,TRUE2,FALSE2),IF(เงื่อนไข 3,TRUE3,FALSE3))
  • 9. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 8  หากนึกถึงคาว่า “ถ้า หาก กรณี ฯลฯ” ให้นึกถึง IF  IF 1 ตัว สามารถแตกกิ่งก้านการตัดสินใจ (Decision Tree) ได้ 2 กิ่ง – ถ ้ำเงื่อนไขเป็นจริง (TRUE) จะทำกำรคำนวณด ้วย สูตรแบบหนึ่ง – ถ ้ำเงื่อนไขเป็นเท็จ (FALSE) จะคำนวณด ้วย สูตรอีกแบบหนึ่ง  ถ้าต้องการให้มีผลลัพธ์การตัดสินใจที่มากกว่า 2 อย่าง ต้องเอา IF หลายตัวมาซ้อนกัน – ในแต่ละกิ่ง ที่ จริง /เท็จ เรำสำมำรถเลือกที่จะใส่ IF ซ ้อนลงไปอีกหรือไม่ก็ได ้ – ในสูตร จำนวนวงเล็บเปิดต ้องเท่ำกับวงเล็บปิดเสมอ  ส่วนเงื่อนไขใช้ร่วมกับฟังก์ชั่นตรรกศาสตร์ได้ ซับซ้อนแค่ไหนก็ได้ – ให ้ผลลัพธ์สุดท ้ำยออกมำเป็น TRUE/FALSE – ฟังก์ชั่นตรรกศำสตร์ เช่น AND, OR, NOT 8
  • 10. inwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcelinwexcel.com พูดคุยกันได้ที่ facebook.com/inwexcel 9  ถ ้ำมีสินค ้ำให ้ลูกค ้ำเลือก 2 ชิ้น จำกสินค ้ำ 4 ชิ้น คือ ก ข ค ง  หำกลูกค ้ำเลือก ก หรือ ค แต่ห ้ำมเลือกทั้ง ก และ ค พร ้อมกัน เรำจะให ้ตัง 1000 บำท กรณีอื่นๆ (รวมถึงเลือก ก และ ค พร ้อมกัน) จะได ้ตัง 500 บำท  สมมติช่อง B1 คือสินค ้ำชิ้นที่ 1, B2 คือ สินค ้ำชิ้นที่ 2  หำกต ้องกำรแสดงเงินรำงวัลที่จะได ้ใน B4 ต ้องเขียนสูตรว่ำอะไร? 9