ThepExcel Logo
  • บทความ
    • Excel
      • Excel ทั่วไป
      • Excel Pivot Table
      • Excel Power Pivot
      • Power Query
      • Excel Array Formula
      • Excel VBA
      • Excel for Business
      • Excel and Maths
      • ฟังก์ชัน Excel ทั้งหมด
    • Power BI
      • Power Query
      • Data Model
      • DAX Formula
      • Power BI Report
    • Coding
      • Excel VBA
      • Python
      • Power Query M Code
    • Highlights : บทความแนะนำ
    • คลิปวีดีโอ
  • อบรม
    • อบรมลูกค้าองค์กร
    • คอร์สออนไลน์ SkillLane
    • แนะนำวิทยากร
    • Excel/Power BI Skill Map
    • Quiz
  • Shop
    • คอร์สออนไลน์
    • สินค้าทั้งหมด
    • หนังสือเล่ม
    • E-Book
    • Cart
  • Download
    • Download ไฟล์จากเทพเอ็กเซล
    • ThepExcel-Mfx : M Code สำเร็จรูป
    • Date Table สำเร็จรูป
    • กราฟ My Skill
    • github.com/ThepExcel
  • รวม Link
    • รวม Link สอน Excel & Power BI ทั้งไทยและเทศ
    • รวม Link สอน Python / Programming
    • หนังสือแนะนำ
    • Facebook ThepExcel
    • YouTube ThepExcel
    • DAX Formatter
  • Contact
    • แนะนำ เทพเอ็กเซล (Thep Excel)
    • แนะนำวิทยากร : อาจารย์ ศิระ เอกบุตร (ระ)
    • นโยบายการคุ้มครองข้อมูลส่วนบุคคล (Privacy Policy)
  • Facebook
  • YouTube

เจาะลึกฟังก์ชัน INDEX : เคล็ดวิชาการใช้งานสูตร INDEX

ฟังก์ชัน index

Categories 📂

Excel Array Formula, Excel ทั่วไป

Tags 🏷️

index, match

ฟังก์ชัน INDEX นั้นเรียกได้ว่าทรงพลังมากที่สุดอันหนึ่งของ Excel สาเหตุสำคัญเป็นเพราะว่ามันมีความสามารถที่หลากหลาย  ในบทความนี้ผมจะพาเพื่อนมารู้จักเจ้า INDEX ให้มากขึ้น ว่ามันทำอะไรได้บ้าง แล้วมุมมองที่คุณมีต่อ INDEX จะเปลี่ยนไปเมื่อคุณได้รู้จักตัวตนที่แท้จริงของมัน

สารบัญ

  • เริ่มกันด้วยพื้นฐาน Basic ๆ
  • 7 เคล็ดวิชาการใช้งานสูตร INDEX
    •  1. สูตร INDEX จริงๆแล้วให้ค่ากลับมาเป็น Cell Reference ไม่ใช่สิ่งที่อยู่ในช่องของพิกัดนั้นๆ
    • 2. เลขลำดับแถว และ คอลัมน์ ถ้าเราใส่ค่าตัวเลขที่มากกว่า 0 จะให้ค่าเป็นจุดพิกัด
    • 3. เลขลำดับแถว และ คอลัมน์ ถ้าเราใส่ค่าเป็น 0 หรือ เว้นว่างไว้ จะให้ค่าเป็นช่วง
    • 4. ตารางอ้างอิง สามารถมีแค่แถวเดียว หรือ คอลัมน์เดียวได้
    • 5. จริงๆ แล้วสูตร INDEX สามารถใช้ตารางอ้างอิงหลายอันได้นะ
    • 6.สูตร INDEX ถ้าใช้ร่วมกับฟังก์ชั่นอื่นเมื่อไหร่ = ไร้เทียมทาน
    • 7. INDEX สามารถประมวลผล Array Formula ได้ โดยไม่ต้องกด Ctrl+Shift+Enter

เริ่มกันด้วยพื้นฐาน Basic ๆ

INDEX อยู่ในฟังก์ชั่นหมวดของ Lookup & Reference โดยเจ้า INDEX มีหน้าที่แบบ Basic ที่สุดก็คือ เอาไว้ “ดึงข้อมูลกลับมาจากตารางอ้างอิงตามพิกัดที่เรากำหนด โดยพิกัดจะต้องระบุเป็นตัวเลขลำดับแถว และลำดับคอลัมน์”

เช่น มีตารางอยู่อันนึง สมมติชื่อ ตารางa มีขนาด 5 แถว x 4 คอลัมน์ เราสามารถกำหนดให้เจ้า INDEX นี่ดึงข้อมูลจากตารางa ในแถวที่ 3 คอลัมน์ที่ 2 กลับมาได้เป็นต้น

index-3

ถ้ามาดูตัวอย่างจริง จากรูป ช่อง B5:E9 ผมตั้งชื่อว่า ตารางa ถ้าผมต้องการค่าจากแถวที่3 คอลัมน์ที่ 2 ของตารางนั้น จะต้องเขียนว่า

= INDEX(ตารางอ้างอิง, ลำดับแถว, ลำดับคอลัมน์)

= INDEX(B5:E9,3,2) หรือ = INDEX(ตารางa,3,2)

ซึ่งจะได้ค่ากลับมาเป็น Tony Stark (เพราะอยู่ที่แถวที่ 3 คอลัมน์ที่ 2 ของตาราง B5:E9)

หยุดก่อน! ถ้าคุณคิดว่า INDEX ทำได้แค่นี้ล่ะก็…ผมจะบอกว่าคุณยังไม่รู้จักมันดีพอ ลองอ่าน 7 เคล็ดวิชาต่อไปนี้ แล้วคุณจะรู้จักมันมากขึ้นอีกเยอะครับ!

7 เคล็ดวิชาการใช้งานสูตร INDEX

 1. สูตร INDEX จริงๆแล้วให้ค่ากลับมาเป็น Cell Reference ไม่ใช่สิ่งที่อยู่ในช่องของพิกัดนั้นๆ

ฟังก์ชัน index

อันนี้เคยพูดไปแล้วใน แฉ 10 ความลับของ Excel ที่คุณอาจยังไม่เคยรู้มาก่อน! แต่จะขอพูดอีกครั้ง เพราะเป็น Concept ที่สำคัญมาก

ในตัวอย่างข้างบน =INDEX(B5:E9,3,2) จริงๆ INDEX จะให้ค่ากลับมาเป็น Cell Reference คือ C7 ก่อน แล้ว Excel จึงแปลง C7 เป็นคำว่า Tony Stark อีกทีหนึ่ง (เป็นเพราะว่าไม่ได้เอา Cell Reference ที่ได้ไปทำอย่างอื่นต่อ จึงคืนค่าในช่องมาให้เลย)

2. เลขลำดับแถว และ คอลัมน์ ถ้าเราใส่ค่าตัวเลขที่มากกว่า 0 จะให้ค่าเป็นจุดพิกัด

จะหมายถึงเอาค่าตามพิกัดลำดับนั้นกลับมาให้เป็น Cell Reference ของ ตารางที่กำหนด ในตำแน่งแถวที่กำหนด คอลัมน์ที่กำหนด

3. เลขลำดับแถว และ คอลัมน์ ถ้าเราใส่ค่าเป็น 0 หรือ เว้นว่างไว้ จะให้ค่าเป็นช่วง

หมายถึง INDEX จะให้ค่ากลับมาเป็น Cell Reference ทุกอันของแถวหรือคอลัมน์นั้นมาเป็นช่วงเลย เช่น

= INDEX(ตารางอ้างอิง, ลำดับแถว, ลำดับคอลัมน์)

= INDEX(ตารางa,0,2) หมายถึง เอาตารางa คอลัมน์ที่ 2 มาเลยทุกแถว จะได้ช่วง C5:C9 นั่นเอง

index-4

= INDEX(ตารางa,3,0) หมายถึง เอาตารางa แถว 3 มาเลยทุกคอลัมน์เอาล่ะครับ จะได้ช่วง B7:E7 นั่นเอง

index-6

= INDEX(ตารางa,0,0) หมายถึง เอาตารางa มาเลยทั้งตาราง ทุกแถว ทุกคอลัมน์ จะได้ช่วง B5:E9 เหมือนเดิม

index-7

ที่นี้การให้ค่ากลับมาเป็น Cell Reference แถมเป็นช่วงอีก เวลาจะเอาไปใช้จริง ก็ต้องเอาไปผสมกับสูตรอื่นๆ อีกทีครับ เช่น AVERAGE, SUM, MATCH เป็นต้น เช่น =SUM(INDEX(ตาราง,0,4)) เป็นต้น

4. ตารางอ้างอิง สามารถมีแค่แถวเดียว หรือ คอลัมน์เดียวได้

ซึ่งถ้าเป็นเช่นนั้น เลขลำดับที่ตามหลังก็สามารถระบุแค่ตัวเดียวพอ ซึ่งมันก็จะเอารายการลำดับที่กำหนดมาให้ เป็นจุดๆ เดียว
แต่ถ้าไม่ระบุ ก็จะเอามาเป็นช่วง คือ ทั้งแถว หรือ คอลัมน์ ตามที่อธิบายไว้ในข้อที่แล้ว

นั่นคือ ถ้ามีตารางอ้างอิงแค่แถวเดียว เลขลำดับที่ตามหลังก็จะเป็นคอลัมน์, ถ้ามีตารางอ้างอิงคอลัมน์เดียว เลขลำดับที่ตามหลังก็จะเป็นแถว
ตัวอย่างเช่น

=INDEX(C5:C9,3)

เพราะมีคอลัมน์เดียว เลข 3 ก็หมายถึงลำดับแถวไปโดยปริยาย ก็จะได้ C7 ซึ่งแปลงเป็นคำว่า Tony Stark เหมือนกัน
index-8

=INDEX(ฺB8:E8,2) เพราะมีแถวเดียว เลข 2 ก็หมายถึงลำดับคอลัมน์ไปโดยปริยาย ก็จะได้ C8 ซึ่งแปลงเป็นคำว่า ชิซูกะ เป็นต้น
index-9

5. จริงๆ แล้วสูตร INDEX สามารถใช้ตารางอ้างอิงหลายอันได้นะ

สูตร INDEX จริงๆ แล้วเขียนได้ 2 แบบ ซึ่งแบบแรก ผมได้พูดไปข้างบนแล้ว แบบนั้นจะใช้ตารางอ้างอิงได้แค่อันเดียว แต่ถ้าเราใช้ INDEX ร่างที่สอง จะสามารถเขียนตารางอ้างอิงได้หลายอัน!! ซึ่งสูตรแบบที่สองเขียนแบบนี้

= INDEX(reference, row_num, [column_num], [area_num])

แปลว่า = INDEX((ตารางอ้างอิง1,ตารางอ้างอิง2,ตารางอ้างอิง3,…,ตารางอ้างอิงn), ลำดับแถว, ลำดับคอลัมน์,ใช้ตารางอ้างอิงที่ท่าไหร่)

ในรูปแบบที่สองนี้ ตารางอ้างอิงมีได้หลายตาราง ซึ่งเราสามารถเลือกได้ว่าจะเอาแถวและคอลัมน์ที่กำหนด จากตารางลำดับที่เท่าไหร่

  • สังเกตว่า reference ในสูตรที่สอง แทนด้วยตารางอ้างอิงหลายอันอยู่ในวงเล็บ คั่นด้วย comma เช่น (ตารางอ้างอิง1,ตารางอ้างอิง2,ตารางอ้างอิง3,…,ตารางอ้างอิงn)
index-10

เช่น ตามรูป เราใส่ตารางอ้างอิงลงไป 2 ตาราง คือ B5:B9 และ B11:E15 ใส่วงเล็บครอบไว้และคั่นไว้ด้วย comma

จากนั้นเราก็เลือกว่าจะเอาแถวที่ 3 คอลัมน์ที่ 4 จากตารางอันที่ 2 มันก็เลยได้ค่าเป็น E13 ซึ่งคือ 175 นั่นเอง

6.สูตร INDEX ถ้าใช้ร่วมกับฟังก์ชั่นอื่นเมื่อไหร่ = ไร้เทียมทาน

สูตร INDEX เป็นพวกขี้เหงา ทำอะไรคนเดียวแล้วทำได้ไม่ค่อยดี แค่หาข้อมูลแบบ VLOOKUP ก็หาไม่ได้
แต่ถ้าเราใช้ INDEX ร่วมกับฟังก์ชั่นอื่นเมื่อไหร่ มันจะแสดงพลังออกมามหาศาล ! เช่น

INDEX + MATCH

index-12
  • MATCH จะค้นหาค่า แล้วส่งผลลัพธ์เป็นตัวเลขกลับมาให้ INDEX ใช้งาน เช่น
    • เราอาจ ใช้ MATCH หาก่อน ว่าคำที่เราต้องการอยู่ใน Row ไหน หรือ Column ไหน
    • =MATCH(คำค้นหา,ช่วงอ้างอิง,รูปแบบการค้นหา)
    • เวลาใช้ผสมกัน จึงใช้ MATCH แทนเลขลำดับพิกัดแถวหรือคอลัมน์ (หรือทั้งคู่) แบบนี้
      = INDEX(ตารางอ้างอิง,MATCH(คำค้นหาแถว,ช่วงอ้างอิงแถว,รูปแบบการค้นหา),MATCH(คำค้นหาคอลัมน์,ช่วงอ้างอิงคอลัมน์,รูปแบบการค้นหา))

7. INDEX สามารถประมวลผล Array Formula ได้ โดยไม่ต้องกด Ctrl+Shift+Enter

อันนี้ก็ตามชื่อหัวข้อครับ ข้อนี้ไม่เข้าใจไม่ต้องซีเรียสไป ใครยังไม่รู้จัก Array Formula เดี๋ยวผมจะเขียนอธิบายในอนาคตครับ (advance มากๆ)

เช่น

=AVERAGE(INDEX((D6:D9="ชาย")*(E6:E9),0,1))

ปกติการทำแบบนี้ (D6:D9=”ชาย”)*(E6:E9) ต้องกด Ctrl+Shift+Enter ไม่งั้นจะ Error
แต่พอมี INDEX มาครอบแล้ว ก็สามารถกด Enter ได้ตามปกติเลยครับ

แชร์ความรู้ให้เพื่อนๆ ของคุณ
65    
65    

ติดตามเทพเอ็กเซล

  • Facebook
  • YouTube

อบรมกับเทพเอ็กเซล

คอร์สออนไลน์ เทพเอ็กเซล
คอร์สออนไลน์ จากเทพเอ็กเซล ดูกี่รอบก็ได้
อบรม Excel / Power BI ให้องค์กรของคุณ

บทความล่าสุด

  • การทำ Simulation ด้วย Excel
  • แกะเคล็ดวิชา Excel Wizard ในการแข่ง Speed Run Excel ระดับโลก
  • เจาะลึก CALCULATE ใน DAX แบบลึกสุดใจ : Part 2
  • วิธีใช้ Power Query ดึงข้อมูล EMS Tracking จากไปรษณีย์ไทย ผ่าน Web API
  • เจาะลึก CALCULATE ใน DAX แบบลึกสุดใจ : Part 1
  • Series สอนดึงข้อมูลจากเว็บ ด้วย Power Automate Desktop
  • ทำความเข้าใจวิธีสั่ง MidJourney แบบละเอียด เพื่อให้ได้ผลลัพธ์ตรงใจ (มากขึ้น)

บทความแนะนำ

🔥ฟังก์ชันทั้งหมดใน Excel 🔥

  • แกะเคล็ดวิชา Excel Wizard ในการแข่ง Speed Run Excel ระดับโลก
  • เจาะลึก CALCULATE ใน DAX แบบลึกสุดใจ : Part 1
  • Series สอนดึงข้อมูลจากเว็บ ด้วย Power Automate Desktop
  • สรุปการใช้ LAMBDA ฟังก์ชันที่ใช้สร้างฟังก์ชันใน Excel 365 และผองเพื่อน
  • วิธีใช้ Excel คำนวณระยะเวลาการทำงานรวม แถมระบุเวลาพักได้แบบยืดหยุ่น
  • วิธีจัดการข้อมูลแย่ๆ ด้วย Power Query ทั้งข้อมูลปนกัน ข้อมูลอยู่บนหัวตาราง
  • แยกข้อมูลที่อยู่สุดเน่า ด้วย Excel Power Query

Categories

Tags

collection concepts copy database Data Model data table data validation date dax dropdown error excel filter finance find format formula function game graph IF index intro iterative len link logic lookup match m code merge mid overview paste pivot power query project row sort speed split substitute table text textjoin time tips trim vba vlookup

Archives

  • January 2023 (1)
  • October 2022 (1)
  • September 2022 (3)
  • August 2022 (3)
  • July 2022 (1)
  • June 2022 (3)
  • May 2022 (1)
  • April 2022 (2)
  • February 2022 (1)
  • December 2021 (2)
  • November 2021 (10)
  • September 2021 (2)
  • August 2021 (6)
  • July 2021 (2)
  • June 2021 (2)
  • May 2021 (10)
  • April 2021 (3)
  • March 2021 (3)
  • February 2021 (4)
  • January 2021 (8)
  • December 2020 (5)
  • November 2020 (13)
  • October 2020 (5)
  • September 2020 (11)
  • August 2020 (4)
  • July 2020 (13)
  • June 2020 (17)
  • May 2020 (16)
  • April 2020 (16)
  • March 2020 (10)
  • February 2020 (15)
  • January 2020 (16)
  • December 2019 (4)
  • November 2019 (3)
  • October 2019 (9)
  • September 2019 (1)
  • August 2019 (7)
  • June 2019 (3)
  • May 2019 (9)
  • April 2019 (9)
  • March 2019 (2)
  • February 2018 (1)
  • January 2018 (3)
  • November 2017 (3)
  • August 2017 (1)
  • July 2017 (1)
  • June 2017 (1)
  • May 2017 (6)
  • April 2017 (6)
  • March 2017 (7)
  • February 2017 (1)
  • January 2017 (2)
  • December 2016 (1)
  • October 2016 (2)
  • September 2016 (3)
  • August 2016 (2)
  • July 2016 (2)
  • June 2016 (1)
  • May 2016 (1)
  • April 2016 (1)
  • March 2016 (2)
  • February 2016 (1)
  • January 2016 (2)
  • December 2015 (2)
  • November 2015 (5)
  • October 2015 (3)
  • June 2015 (2)
  • May 2015 (1)
  • April 2015 (26)
  • January 2015 (1)
  • December 2014 (1)
  • November 2014 (2)
  • October 2014 (1)
  • September 2014 (2)
  • August 2014 (1)
  • June 2014 (1)
  • May 2014 (1)
  • April 2014 (3)
  • March 2014 (3)
  • February 2014 (12)
  • January 2014 (7)
  • December 2013 (2)
  • November 2013 (8)
  • October 2013 (2)

เทพเอ็กเซล : Thep Excel

copyright © 2022

  • Facebook
  • YouTube
เว็บไซต์นี้ใช้คุกกี้ (Cookies)
บริษัท เทพเอ็กเซล จำกัด ให้ความสำคัญต่อข้อมูลส่วนบุคคลของท่าน เพื่อการพัฒนาและปรับปรุงเว็บไซต์รวมถึงสินค้าและบริการต่างๆ หากท่านใช้บริการเว็บไซต์นี้ โดยไม่มีการปรับตั้งค่าใดๆ แสดงว่าท่านยินยอมที่จะรับคุกกี้บนเว็บไซต์ และนโยบายสิทธิส่วนบุคคลของเรา
ตั้งค่าคุกกี้ยอมรับทั้งหมดอ่านเพิ่มเติม
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT