انتقل إلى المحتوى الرئيسي

كيفية إرجاع قيم بحث متعددة في خلية واحدة مفصولة بفاصلة؟

في Excel ، يمكننا تطبيق دالة VLOOKUP لإرجاع القيمة المطابقة الأولى من خلايا جدول ، ولكن في بعض الأحيان ، نحتاج إلى استخراج جميع القيم المطابقة ثم فصلها بمحدد معين ، مثل الفاصلة والشرطة وما إلى ذلك ... في واحد الخلية كما هو موضح في لقطة الشاشة التالية. كيف يمكننا الحصول على قيم بحث متعددة وإرجاعها في خلية واحدة مفصولة بفاصلة في Excel؟

يُرجع المستند قيمًا متعددة مفصولة بفاصلة 1

قم بإرجاع قيم بحث متعددة في خلية واحدة مفصولة بفاصلة بوظيفة محددة من قبل المستخدم

قم بإرجاع قيم بحث متعددة في خلية واحدة مفصولة بفاصلة باستخدام Kutools for Excel


قم بإرجاع قيم بحث متعددة في خلية واحدة مفصولة بفاصلة بوظيفة محددة من قبل المستخدم

في العادة ، لا توجد طريقة مباشرة لنا لاستخراج وإرجاع قيم المطابقة المتعددة وفصلها بفاصلة في خلية واحدة ، هنا ، يمكنك إنشاء وظيفة محددة بواسطة المستخدم لحل هذه المهمة ، يرجى القيام بما يلي:

1. اضغط باستمرار على ALT + F11 مفاتيح لفتح ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

2. انقر إدراج > وحدة، والصق الكود التالي في ملف وحدة نافذة او شباك.

رمز فبا: إرجاع قيم بحث متعددة في خلية واحدة مفصولة بفاصلة

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،XNUMX، "،") في خلية فارغة تريد إرجاع النتيجة. ثم اضغط على أدخل مفتاح للحصول على النتيجة ، انظر لقطة الشاشة:

يُرجع المستند قيمًا متعددة مفصولة بفاصلة 2

ملاحظات: في الصيغة أعلاه:

D2: يشير إلى قيم الخلية التي تريد البحث عنها ؛

أ 2: ب 15: هو نطاق البيانات الذي تريد جلب البيانات ؛

2: الرقم 2 هو رقم العمود الذي سيتم إرجاع القيمة المطابقة ؛

,: الفاصلة هي الفاصل الذي تريده لفصل القيم المتعددة.

يمكنك تغييرها حسب حاجتك.


قم بإرجاع قيم بحث متعددة في خلية واحدة مفصولة بفاصلة باستخدام Kutools for Excel

إذا كان لديك كوتولس ل إكسيل، هذه المهمة لن تكون مشكلة بعد الآن. ال الجمع بين الصفوف المتقدمة قد تساعدك الأداة المساعدة في دمج جميع القيم النسبية بناءً على عمود.

كوتولس ل إكسيل : مع أكثر من 300 وظيفة إضافية مفيدة في Excel ، يمكنك تجربتها مجانًا دون قيود في أيام 30

بعد تثبيت كوتولس ل إكسيليرجى القيام بما يلي:

1. حدد نطاق البيانات الذي تريده لدمج كل القيم المتطابقة بناءً على عمود.

2. انقر كوتولس > دمج وتقسيم > الجمع بين الصفوف المتقدمة، انظر لقطة الشاشة:

3. في ضم الصفوف على أساس العمود في مربع الحوار ، انقر فوق اسم العمود الذي تريد الدمج بناءً عليه ، ثم انقر فوق "موافق" المفتاح الأساسي زر ، انظر لقطة الشاشة:

يُرجع المستند قيمًا متعددة مفصولة بفاصلة 4

4. ثم انقر فوق اسم العمود الآخر الذي تريد دمج قيمها المتطابقة ، وانقر فوق دمج لاختيار فاصل واحد لفصل القيم المجمعة ، انظر الصورة:

يُرجع المستند قيمًا متعددة مفصولة بفاصلة 5

5. ثم اضغط OK الزر ، تم دمج جميع الخلايا المقابلة بنفس القيمة في خلية واحدة مفصولة بفاصلة ، انظر لقطات الشاشة:

يُرجع المستند قيمًا متعددة مفصولة بفاصلة 6 2 يُرجع المستند قيمًا متعددة مفصولة بفاصلة 7

انقر لمعرفة المزيد من التفاصيل حول هذه الأداة المساعدة Advanced Combine Rows ...

قم بتنزيل Kutools for Excel والإصدار التجريبي المجاني الآن!


عرض توضيحي: قم بإرجاع قيم بحث متعددة في خلية واحدة مفصولة بفاصلة باستخدام Kutools for Excel

كوتولس ل إكسيل: مع أكثر من 300 وظيفة إضافية مفيدة في Excel ، يمكنك تجربتها مجانًا دون قيود خلال 30 يومًا. تنزيل وتجربة مجانية الآن!

أفضل أدوات إنتاجية المكتب

🤖 مساعد Kutools AI: إحداث ثورة في تحليل البيانات على أساس: التنفيذ الذكي   |  إنشاء التعليمات البرمجية  |  إنشاء صيغ مخصصة  |  تحليل البيانات وإنشاء الرسوم البيانية  |  استدعاء وظائف Kutools...
الميزات الشعبية: البحث عن التكرارات أو تمييزها أو تحديدها   |  حذف الصفوف الفارغة   |  دمج الأعمدة أو الخلايا دون فقدان البيانات   |   جولة بدون صيغة 
سوبر بحث: معايير متعددة VLookup    VLookup ذات القيمة المتعددة  |   VLookup عبر أوراق متعددة   |   بحث غامض ....
قائمة منسدلة متقدمة: إنشاء القائمة المنسدلة بسرعة   |  القائمة المنسدلة التابعة   |  قائمة منسدلة متعددة التحديد ....
مدير العمود: إضافة عدد محدد من الأعمدة  |  نقل الأعمدة  |  تبديل حالة رؤية الأعمدة المخفية  |  مقارنة النطاقات والأعمدة 
الميزات المميزة: التركيز على الشبكة   |  عرض تصميم   |   شريط الفورمولا الكبير    مدير المصنفات والأوراق   |  مكتبة الموارد (النص السيارات)   |  منتقي التاريخ   |  اجمع أوراق العمل   |  تشفير/فك تشفير الخلايا    إرسال رسائل البريد الإلكتروني عن طريق القائمة   |  سوبر تصفية   |   مرشح خاص (تصفية غامق / مائل / يتوسطه خط ...) ...
أفضل 15 مجموعة أدوات12 نص الأدوات (إضافة نص, إزالة الأحرف، ...)   |   +50 رسم الأنواع (مخطط جانت، ...)   |   40+ عملي الصيغ (احسب العمر على أساس تاريخ الميلاد، ...)   |   19 إدخال الأدوات (أدخل رمز الاستجابة السريعة, إدراج صورة من المسار، ...)   |   12 تحويل الأدوات (أرقام إلى كلمات, نتيجة تحويل عملة، ...)   |   7 دمج وتقسيم الأدوات (الجمع بين الصفوف المتقدمة, تقسيم الخلايا، ...)   |   ... و اكثر

عزز مهاراتك في Excel باستخدام Kutools for Excel، واختبر كفاءة لم يسبق لها مثيل. يقدم Kutools for Excel أكثر من 300 ميزة متقدمة لتعزيز الإنتاجية وتوفير الوقت.  انقر هنا للحصول على الميزة التي تحتاجها أكثر...

الوصف


يجلب Office Tab الواجهة المبوبة إلى Office ، ويجعل عملك أسهل بكثير

  • تمكين التحرير والقراءة المبوبة في Word و Excel و PowerPointوالناشر والوصول و 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