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

จะคืนค่าการค้นหาหลายค่าในเซลล์ที่คั่นด้วยจุลภาคหนึ่งเซลล์ได้อย่างไร

ใน Excel เราสามารถใช้ฟังก์ชัน VLOOKUP เพื่อส่งคืนค่าที่ตรงกันแรกจากเซลล์ตาราง แต่บางครั้งเราจำเป็นต้องแยกค่าที่ตรงกันทั้งหมดแล้วคั่นด้วยตัวคั่นเฉพาะเช่นลูกน้ำเส้นประ ฯลฯ ... เป็นค่าเดียว เซลล์ดังภาพหน้าจอต่อไปนี้ที่แสดง เราจะรับและส่งคืนค่าการค้นหาหลายค่าในเซลล์ที่คั่นด้วยจุลภาคหนึ่งเซลล์ใน Excel ได้อย่างไร

doc ส่งคืนค่าหลายค่าโดยคั่นด้วยเครื่องหมายจุลภาค 1

ส่งคืนค่าการค้นหาหลายค่าในเซลล์ที่คั่นด้วยจุลภาคหนึ่งเซลล์ด้วยฟังก์ชันที่กำหนดโดยผู้ใช้

ส่งคืนค่าการค้นหาหลายค่าในเซลล์ที่คั่นด้วยจุลภาคหนึ่งเซลล์ด้วย Kutools for Excel


ส่งคืนค่าการค้นหาหลายค่าในเซลล์ที่คั่นด้วยจุลภาคหนึ่งเซลล์ด้วยฟังก์ชันที่กำหนดโดยผู้ใช้

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

1. กด ALT + F11 คีย์เพื่อเปิด Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

2. คลิก สิ่งที่ใส่เข้าไป > โมดูลและวางรหัสต่อไปนี้ในไฟล์ โมดูล หน้าต่าง.

รหัส VBA: ส่งคืนค่าการค้นหาหลายค่าในเซลล์ที่คั่นด้วยจุลภาคหนึ่งเซลล์

Function SingleCellExtract(LookupValue As String, LookupRange As Range, ColumnNumber As Integer, Char As String)
'Updateby Extendoffice
    Dim I As Long
    Dim xRet As String
    For I = 1 To LookupRange.Columns(1).Cells.Count
        If LookupRange.Cells(I, 1) = LookupValue Then
            If xRet = "" Then
                xRet = LookupRange.Cells(I, ColumnNumber) & Char
            Else
                xRet = xRet & "" & LookupRange.Cells(I, ColumnNumber) & Char
            End If
        End If
    Next
    SingleCellExtract = Left(xRet, Len(xRet) - 1)
End Function

3. จากนั้นบันทึกรหัสนี้และปิดหน้าต่างโมดูลกลับไปที่แผ่นงานของคุณแล้วป้อนสูตรนี้: = SingleCellExtract (D2, A2: B15,2, ",") ลงในเซลล์ว่างที่คุณต้องการส่งคืนผลลัพธ์ จากนั้นกด เข้าสู่ กุญแจสำคัญในการรับผลลัพธ์ดูภาพหน้าจอ:

doc ส่งคืนค่าหลายค่าโดยคั่นด้วยเครื่องหมายจุลภาค 2

หมายเหตุ: ในสูตรข้างต้น:

D2: ระบุค่าเซลล์ที่คุณต้องการค้นหา

A2: B15: คือช่วงข้อมูลที่คุณต้องการดึงข้อมูล

2: หมายเลข 2 คือหมายเลขคอลัมน์ที่จะส่งคืนค่าที่ตรงกัน

,: ลูกน้ำคือตัวคั่นที่คุณต้องการแยกหลายค่า

คุณสามารถเปลี่ยนได้ตามความต้องการของคุณ


ส่งคืนค่าการค้นหาหลายค่าในเซลล์ที่คั่นด้วยจุลภาคหนึ่งเซลล์ด้วย Kutools for Excel

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

Kutools สำหรับ Excel : ด้วย Add-in ของ Excel ที่มีประโยชน์มากกว่า 300 รายการทดลองใช้ฟรีโดยไม่มีข้อ จำกัด ใน 30 วัน

หลังจากการติดตั้ง Kutools สำหรับ Excelโปรดดำเนินการดังนี้:

1. เลือกช่วงข้อมูลที่คุณต้องการรวมค่าที่ตรงกันทั้งหมดตามคอลัมน์

2. คลิก Kutools > ผสานและแยก > แถวรวมขั้นสูงดูภาพหน้าจอ:

3. ใน รวมแถวตามคอลัมน์ กล่องโต้ตอบคลิกชื่อคอลัมน์ที่คุณต้องการรวมจากนั้นคลิก คีย์หลัก ปุ่มดูภาพหน้าจอ:

doc ส่งคืนค่าหลายค่าโดยคั่นด้วยเครื่องหมายจุลภาค 4

4. จากนั้นคลิกชื่อคอลัมน์อื่นที่คุณต้องการรวมค่าที่ตรงกันแล้วคลิก รวมกัน ในการเลือกตัวคั่นหนึ่งตัวเพื่อแยกค่ารวมดูภาพหน้าจอ:

doc ส่งคืนค่าหลายค่าโดยคั่นด้วยเครื่องหมายจุลภาค 5

5. จากนั้นคลิก OK เซลล์ที่เกี่ยวข้องทั้งหมดที่มีค่าเดียวกันรวมกันเป็นเซลล์เดียวซึ่งคั่นด้วยเครื่องหมายจุลภาคโปรดดูภาพหน้าจอ:

doc ส่งคืนค่าหลายค่าโดยคั่นด้วยเครื่องหมายจุลภาค 6 2 doc ส่งคืนค่าหลายค่าโดยคั่นด้วยเครื่องหมายจุลภาค 7

คลิกเพื่อดูรายละเอียดเพิ่มเติมเกี่ยวกับยูทิลิตี้ Advanced Combine Rows ...

ดาวน์โหลดและทดลองใช้ Kutools for Excel ฟรีทันที!


Demo: ส่งคืนค่าการค้นหาหลายค่าในเซลล์ที่คั่นด้วยจุลภาคหนึ่งเซลล์ด้วย Kutools for Excel

Kutools สำหรับ Excel: ด้วย Add-in ของ Excel ที่มีประโยชน์มากกว่า 300 รายการให้ทดลองใช้ฟรีโดยไม่มีข้อ จำกัด ใน 30 วัน ดาวน์โหลดและทดลองใช้ฟรีทันที!

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

🤖 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 (16)
Rated 5 out of 5 · 2 ratings
This comment was minimized by the moderator on the site
No soy programador pero necesito ayuda para que la función de abajo en lugar de devolverme esto

S-01-08-0017->Micro Post 1R, Black, Stainless Steel -End,->4;S-01-08-0057->Micro Post 2R, Black, Stainless Steel -End,->2

me devuelva los valores en líneas diferentes.
S-01-08-0017->Micro Post 1R, Black, Stainless Steel -End,->4
S-01-08-0057->Micro Post 2R, Black, Stainless Steel -End,->2

La función es:
Function SingleCellExtract(LookupValue As String, LookupRange As Range, ColumnNumber As Integer, Char As String)
'Updateby Extendoffice
Dim I As Long
Dim xRet As String
For I = 1 To LookupRange.Columns(1).Cells.Count
If LookupRange.Cells(I, 1) = LookupValue Then
If xRet = "" Then
xRet = LookupRange.Cells(I, ColumnNumber) & Char
Else
xRet = xRet & "" & LookupRange.Cells(I, ColumnNumber) & Char
End If
End If
Next
SingleCellExtract = Left(xRet, Len(xRet) - 1)
End Function
This comment was minimized by the moderator on the site
Hello, Yery,
Did you mean to split a cell into multiple rows based on the semicolon character?
If so, the following VBA code can help you:
Sub SplitAll()
    Dim xRg As Range
    Dim xRg1 As Range
    Dim xCell As Range
    Dim I As Long
    Dim xAddress As String
    Dim xUpdate As Boolean
    Dim xRet As Variant
    On Error Resume Next
    xAddress = Application.ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select a range", "Kutools for Excel", xAddress, , , , , 8)
    Set xRg = Application.Intersect(xRg, xRg.Worksheet.UsedRange)
    If xRg Is Nothing Then Exit Sub
        If xRg.Columns.Count > 1 Then
            MsgBox "You can't select multiple columns", , "Kutools for Excel"
            Exit Sub
            End If
            Set xRg1 = Application.InputBox("Split to (single cell):", "Kutools for Excel", , , , , , 8)
            Set xRg1 = xRg1.Range("A1")
            If xRg1 Is Nothing Then Exit Sub
                xUpdate = Application.ScreenUpdating
                Application.ScreenUpdating = False
                For Each xCell In xRg
                    xRet = Split(xCell.Value, ";")
                    xRg1.Worksheet.Range(xRg1.Offset(I, 0), xRg1.Offset(I + UBound(xRet, 1), 0)) = Application.WorksheetFunction.Transpose(xRet)
                    I = I + UBound(xRet, 1) + 1
                Next
                Application.ScreenUpdating = xUpdate
            End Sub

Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Hi,

I want exact validation code for multiple values separated by comma and space for each value.

Example:
Lucy, Tom, Nicol, Akash, Apple

Please replay if you have any suggestions.
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
Hello, Manikanta
To separate the multiple values by a comma and space, you just need to add a space behind the comma, change the formula as this: =SingleCellExtract(D2,A2:B15,2,", ").
Please try, hope it can help you!
This comment was minimized by the moderator on the site
Hi Skyyang,

Thanks for your replay!

I tried already same way but in the cell value last one extra comma (,) coming below is the example.

Lucy, Tom, Nicol, Akash, Apple,

This will not work for Json file, so I want values separated by comma and space like below.

Lucy, Tom, Nicol, Akash, Apple

Thank you!
This comment was minimized by the moderator on the site
Hello, Manikanta
In this case, you can apply the below User Defined Function:

Function MultipleValues(work_range As Range, criteria As Variant, merge_range As Range, Optional Separator As String = ",") As Variant
Dim outcome As String
On Error Resume Next
If work_range.Count <> merge_range.Count Then
MultipleValues = CVErr(xlErrRef)
Exit Function
End If
For i = 1 To work_range.Count
If work_range.Cells(i).Value = criteria Then
outcome = outcome & Separator & merge_range.Cells(i).Value
End If
Next i
If outcome <> "" Then
outcome = VBA.Mid(outcome, VBA.Len(Separator) + 1)
End If
MultipleValues = outcome
Exit Function
End Function


After pasting the code, please use this formula: =MultipleValues($A$2:$A$15,D2,$B$2:$B$15,", ")

Please try, hope this can help you!
If you still have any other problem, please comment here.
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-return-multiple-matching-1.png
This comment was minimized by the moderator on the site
Hi Skyyang,

This is working now, Thank you for your quick response.

It's very use full to me once again Thank you for your help.

Regards,
Manikanta.
Rated 5 out of 5
This comment was minimized by the moderator on the site
Good Morning,

the VBA code worked perfectly with my worksheet, pretty clear and simple, however, I was trying to find a way to tell excel to only return the unique values. Would that be possible using this same code?
Rated 5 out of 5
This comment was minimized by the moderator on the site
When 2 Criteria Match then Return Multiple Lookup Values In One Comma Separated Cell
A2=B2 Then Result From Range by "SingleCellExtract" - Please.......
This comment was minimized by the moderator on the site
Error pops up if increase the array size
This comment was minimized by the moderator on the site
VB command breaks when the range is longer than 154 rows (ie :B154)....
This comment was minimized by the moderator on the site
thank you, firstly i managed to get this to work without the slow down in performance. I'm using values rather that text so my question is i want to bring back all those with less than say 19 points in a list. Can the single cell Extract work for that or does it have to be a specific value?
This comment was minimized by the moderator on the site
This simply does not work. I was unable to get it to work in my own application, so I copy/pasted the vba and the formula and it returned an error every time
This comment was minimized by the moderator on the site
This works but slows down my excel majorly! Any tips to help speed?
This comment was minimized by the moderator on the site
Thanks for this post. Do you know how I would go about manipulating the two separate integers this is creating. For example, lets say that the '=SingleCellExtract' function now produces (1 , 2). Is there a way to have a cell next to it that does (1+.5 , 2+.5)?
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