ไปยังเนื้อหาหลัก

วิธีดึงข้อมูลจากแผนภูมิหรือกราฟใน Excel

doc-extract-chart-data-1
ใน Excel เรามักจะใช้แผนภูมิเพื่อแสดงข้อมูลและแนวโน้มเพื่อการดูที่ชัดเจนยิ่งขึ้น แต่ในบางครั้งแผนภูมิอาจเป็นสำเนาและคุณไม่มีข้อมูลต้นฉบับของแผนภูมิดังภาพด้านล่างที่แสดง ในกรณีนี้คุณอาจต้องการดึงข้อมูลจากแผนภูมินี้ ตอนนี้บทช่วยสอนนี้กำลังพูดถึงการดึงข้อมูลจากแผนภูมิหรือกราฟ
ดึงข้อมูลจากแผนภูมิด้วย VBA

ลูกศรสีฟ้าฟองขวา ดึงข้อมูลจากแผนภูมิด้วย VBA

1. คุณต้องสร้างแผ่นงานใหม่และเปลี่ยนชื่อเป็น ข้อมูลแผนภูมิ. ดูภาพหน้าจอ:

doc-extract-chart-data-5

2. จากนั้นเลือกแผนภูมิที่คุณต้องการดึงข้อมูลจากนั้นกด Alt + F11 คีย์พร้อมกันและก Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่างปรากฏขึ้น

3 คลิก สิ่งที่ใส่เข้าไป > โมดูลจากนั้นวางโค้ด VBA ด้านล่างลงใน popping โมดูล หน้าต่าง

VBA: ดึงข้อมูลจากแผนภูมิ

Sub GetChartValues()
    'Updateby20220510
    Dim xNum As Integer
    Dim xSeries As Object
    On Error Resume Next
    xCount = 2
    xNum = UBound(Application.ActiveChart.SeriesCollection(1).Values)
    Application.Worksheets("ChartData").Cells(1, 1) = "X Values"
    With Application.Worksheets("ChartData")
        .Range(.Cells(2, 1), _
        .Cells(xNum + 1, 1)) = _
        Application.Transpose(ActiveChart.SeriesCollection(1).XValues)
    End With
    For Each xSeries In Application.ActiveChart.SeriesCollection
        Application.Worksheets("ChartData").Cells(1, xCount) = xSeries.Name
        With Application.Worksheets("ChartData")
            .Range(.Cells(2, xCount), _
            .Cells(xNum + 1, xCount)) = _
            Application.WorksheetFunction.Transpose(xSeries.Values)
        End With
        xCount = xCount + 1
    Next
End Sub

4 จากนั้นคลิก วิ่ง เพื่อเรียกใช้ VBA ดูภาพหน้าจอ:

doc-extract-chart-data-2

จากนั้นคุณจะเห็นข้อมูลถูกดึงไปที่ ข้อมูลแผนภูมิ แผ่น.
doc-extract-chart-data-3

เคล็ดลับ:

1. คุณสามารถจัดรูปแบบเซลล์ได้ตามที่คุณต้องการ

doc-extract-chart-data-4

2. ข้อมูลของแผนภูมิที่เลือกจะถูกแยกไปยังเซลล์แรกของแผ่นงาน ChartData เป็นค่าเริ่มต้น


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

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

🤖 Kutools AI ผู้ช่วย: ปฏิวัติการวิเคราะห์ข้อมูลโดยยึดตาม: การดำเนินการที่ชาญฉลาด   |  สร้างรหัส  |  สร้างสูตรที่กำหนดเอง  |  วิเคราะห์ข้อมูลและสร้างแผนภูมิ  |  เรียกใช้ฟังก์ชัน Kutools...
คุณสมบัติยอดนิยม: ค้นหา เน้น หรือระบุรายการที่ซ้ำกัน   |  ลบแถวว่าง   |  รวมคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล   |   รอบโดยไม่มีสูตร ...
การค้นหาขั้นสูง: VLookup หลายเกณฑ์    VLookup หลายค่า  |   VLookup ข้ามหลายแผ่น   |   การค้นหาที่ไม่ชัดเจน ....
รายการแบบเลื่อนลงขั้นสูง: สร้างรายการแบบหล่นลงอย่างรวดเร็ว   |  รายการแบบหล่นลงขึ้นอยู่กับ   |  เลือกหลายรายการแบบหล่นลง ....
ผู้จัดการคอลัมน์: เพิ่มจำนวนคอลัมน์เฉพาะ  |  ย้ายคอลัมน์  |  สลับสถานะการมองเห็นของคอลัมน์ที่ซ่อนอยู่  |  เปรียบเทียบช่วงและคอลัมน์ ...
คุณสมบัติเด่น: กริดโฟกัส   |  มุมมองการออกแบบ   |   บาร์สูตรใหญ่    สมุดงานและตัวจัดการชีต   |  ห้องสมุดทรัพยากร (ข้อความอัตโนมัติ)   |  เลือกวันที่   |  รวมแผ่นงาน   |  เข้ารหัส/ถอดรหัสเซลล์    ส่งอีเมลตามรายการ   |  ซุปเปอร์ฟิลเตอร์   |   ตัวกรองพิเศษ (กรองตัวหนา/ตัวเอียง/ขีดทับ...) ...
ชุดเครื่องมือ 15 อันดับแรก12 ข้อความ เครื่องมือ (เพิ่มข้อความ, ลบอักขระ, ... )   |   50 + แผนภูมิ ประเภท (แผนภูมิ Gantt, ... )   |   40+ ใช้งานได้จริง สูตร (คำนวณอายุตามวันเกิด, ... )   |   19 การแทรก เครื่องมือ (ใส่ QR Code, แทรกรูปภาพจากเส้นทาง, ... )   |   12 การแปลง เครื่องมือ (ตัวเลขเป็นคำ, การแปลงสกุลเงิน, ... )   |   7 ผสานและแยก เครื่องมือ (แถวรวมขั้นสูง, แยกเซลล์, ... )   |   ... และอื่น ๆ

เพิ่มพูนทักษะ Excel ของคุณด้วย Kutools สำหรับ Excel และสัมผัสประสิทธิภาพอย่างที่ไม่เคยมีมาก่อน Kutools สำหรับ Excel เสนอคุณสมบัติขั้นสูงมากกว่า 300 รายการเพื่อเพิ่มประสิทธิภาพและประหยัดเวลา  คลิกที่นี่เพื่อรับคุณสมบัติที่คุณต้องการมากที่สุด...

รายละเอียด


แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก

  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
Comments (18)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Amazing...
This comment was minimized by the moderator on the site
Very helpful! Thanks a lot!
This comment was minimized by the moderator on the site
giving error and tell to set block variables and object variables
This comment was minimized by the moderator on the site
Hi, I have updated the VBA, you can try it again.
This comment was minimized by the moderator on the site
i tried above & it says "Compile error: Method or Data Member not found"
This comment was minimized by the moderator on the site
mong mọi người giúp đỡ làm cách nào để lấy số liệu từ biểu đồ này với ạ!
This comment was minimized by the moderator on the site
i m getting below error while running that command.
this error comes in that command which starts from xnum = UBound(......) etc

Run-Time error '91'
object variable or with block variable not set
This comment was minimized by the moderator on the site
Hi, tarshul, you need to create a new worksheet named ChartData before you running the code, the data will be place in the new worksheet ChartData.
This comment was minimized by the moderator on the site
Hi sunny,
I already create new worksheet as u told but still getting same error.
This comment was minimized by the moderator on the site
This doesn't appear to work for a scatter plot as it only extracts one set of "x" data. How can I amend it to extract all "x" data sets?
This comment was minimized by the moderator on the site
Sorry I did not found the solution about that.
This comment was minimized by the moderator on the site
i've tried with a scatter plot graph as well, but only get one line of valor.


i need so much to find a way to extract data from scatterplot graphs.
This comment was minimized by the moderator on the site
I failed to get the prices of a fund chart on my mac excel 2011 . Run time error '91' object variable or block variable not set . Don't know how to debug . Appreciate any help .
This comment was minimized by the moderator on the site
Very useful and perfect
This comment was minimized by the moderator on the site
gives me values that i created chart with not all the values in range
This comment was minimized by the moderator on the site
Amazing command, thanks a lot! I used it with a pivot chart and it works!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations