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

كيفية البحث عن القيمة المطابقة وإرجاعها مع تعليق الخلية؟

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

Vlookup وإرجاع القيمة المطابقة مع تعليق الخلية باستخدام التعليمات البرمجية لـ VBA


Vlookup وإرجاع القيمة المطابقة مع تعليق الخلية باستخدام التعليمات البرمجية لـ VBA

قد يساعدك رمز VBA أدناه في البحث عن القيمة المتطابقة وإرجاعها بتعليقها ، يرجى القيام بما يلي:

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

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

كود VBA: Vlookup وإرجاع قيمة مطابقة مع تعليق الخلية:

Function VlookupComment(LookVal As Variant, FTable As Range, FColumn As Long, FType As Long) As Variant
'Updateby Extendoffice
    Application.Volatile
    Dim xRet As Variant 'could be an error
    Dim xCell As Range
    xRet = Application.Match(LookVal, FTable.Columns(1), FType)
    If IsError(xRet) Then
        VlookupComment = "Not Found"
    Else
        Set xCell = FTable.Columns(FColumn).Cells(1)(xRet)
        VlookupComment = xCell.Value
        With Application.Caller
            If Not .Comment Is Nothing Then
                .Comment.Delete
            End If
            If Not xCell.Comment Is Nothing Then
                .AddComment xCell.Comment.Text
            End If
        End With
    End If
End Function

3. ثم احفظ الكود وأغلق نافذة الكود ، أدخل هذه الصيغة: = vlookupcomment (H2، A2: C10,3،XNUMX، FALSE) في خلية فارغة لتحديد موقع النتيجة ، واضغط على أدخل المفتاح ، يتم إرجاع القيمة المتطابقة بالإضافة إلى التعليق مرة واحدة ، انظر لقطة الشاشة:

ملاحظات: في الصيغة أعلاه ، H2 هي قيمة البحث التي تريد إرجاع قيمتها المقابلة ، A2: C10 هو جدول البيانات الذي تريد استخدامه ، الرقم 3 هو رقم العمود الذي يحتوي على القيمة المطابقة التي تريد إرجاعها.

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

🤖 مساعد 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 (20)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
txs a lot. highly appreciated!
This comment was minimized by the moderator on the site
Hello this is a very good function, but it works for Notes, not Comments (this is how it is translated in my native language at least). Is there some way to change it from Notes to Comments? Also, is there a way to keep the cell format? (color of the original cell, etc).
This comment was minimized by the moderator on the site
i've had the same issue. i can only say that having tried via vba to copy comments and notes... only notes are being copied, not the comments (although the have the same meaning, but a different functionality)... Notes seem to be of a static nature, unlike comments where you can keep "posting" to adding new text...Probably that's the reason....
This comment was minimized by the moderator on the site
Hi, fana,
To extract the matched records with the comment in Office 365, please apply the below code:
Function VlookupComment(LookVal As Variant, FTable As Range, FColumn As Long, FType As Long) As Variant
'Updateby Extendoffice
    Application.Volatile
    Dim xRet As Variant 'could be an error
    Dim xCell As Range
    xRet = Application.Match(LookVal, FTable.Columns(1), FType)
    If IsError(xRet) Then
        VlookupComment = "Not Found"
    Else
        Set xCell = FTable.Columns(FColumn).Cells(1)(xRet)
        VlookupComment = xCell.Value
        With Application.Caller
            If Not .CommentThreaded Is Nothing Then
                .ClearComments
            End If
            If Not xCell.CommentThreaded Is Nothing Then
                .AddCommentThreaded xCell.CommentThreaded.Text
            End If
        End With
    End If
End Function


After pasting the code, apply this formula: =vlookupcomment(H2,A2:C10,3,FALSE) as well.

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Not working for me. I get #NAME? error when i use this formula. Please help.
This comment was minimized by the moderator on the site
Hello, Sajjad,Did you put the VBA code of this article into your workbook? Please check it.Or which Excel version do you use?Thank you!
This comment was minimized by the moderator on the site
This is a wonderful. But when using this code I find the file crashes a lot on Excel 365. when removing auto save I found it’s a little better. But with multiple users in the file, the file will crash all the time. Does this code use a lot of memory or is it a compatibility issue? Thoughts? Thanks
This comment was minimized by the moderator on the site
Hi! I'm so glad I found this, the thing is, this actually works on notes, and not comments. is there a way to have work on comments and not notes? in notes i cannot tag my coworkers and i cannot reply either. thanks a lot!
This comment was minimized by the moderator on the site
i can do that at the first time. but after i try to use changing formula of multiple cells. It doesn't work now. after even i type vlookupcomment, the cell becomes blank.
This comment was minimized by the moderator on the site
My comment is too large for the default box size. Is there any way to increase the comment box size or possibly decrease the font size?
This comment was minimized by the moderator on the site
If anyone else needs this.


Function VlookupComment(LookVal As Variant, FTable As Range, FColumn As Long, FType As Long) As Variant

'Updateby Extendoffice

Application.Volatile

Dim xRet As Variant 'could be an error

Dim xCell As Range

xRet = Application.Match(LookVal, FTable.Columns(1), FType)

If IsError(xRet) Then

VlookupComment = "-"

Else

Set xCell = FTable.Columns(FColumn).Cells(1)(xRet)

VlookupComment = xCell.Value

With Application.Caller

If Not .Comment Is Nothing Then

.Comment.Delete

End If

If Not xCell.Comment Is Nothing Then

.AddComment xCell.Comment.Text

.Comment.Shape.ScaleWidth 2, msoFalse, msoScaleFromTopLeft

.Comment.Shape.ScaleHeight 2.5, msoFalse, msoScaleFromTopLeft

End If

End With

End If

End Function
This comment was minimized by the moderator on the site
I want only Comment as Cell Value using Vlookup...
This comment was minimized by the moderator on the site
Thanks, It's helpful & I have something to askIt returns with cell comment but the Image (Inserted using fill effects ) does not show
Please , help me out of this Issue
This comment was minimized by the moderator on the site
Shamim,
Sorry for that there is no direct code for solving your problem, if anyone has the solution, please comment here.
This comment was minimized by the moderator on the site
Frank
Hello,

In case of spreadsheet protected, when I open my workbook the cell return the error #VALUE!

How we can solve this problem?
This comment was minimized by the moderator on the site
Hello, Frank,
After inserting the code, you should save your workbook as Excel Macro-Enabled Workbook format, so that the code will not lose.
Please try! Thank you!
This comment was minimized by the moderator on the site
Can we use cell in column B (order column) as comment for cell in column C (name). exc, comment for Helen is 80.
thank you for your help.
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