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

كيفية تلوين أو تمييز كلمة معينة في الخلايا في إكسيل؟

إذا كانت الخلية تحتوي على كلمات متعددة ، كيف يمكنك تمييز كلمة معينة فقط في هذه الخلية؟ وماذا عن تمييز هذه الكلمة المعينة في خلايا متعددة؟ ستوفر هذه المقالة طريقة لتحقيق ذلك.

قم بتلوين كلمة معينة في خلية واحدة / خلايا متعددة برمز VBA


قم بتلوين كلمة معينة في خلية واحدة / خلايا متعددة برمز VBA

يمكن أن يساعدك رمز VBA التالي في تمييز كلمة معينة في التحديد. الرجاء القيام بما يلي.

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

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

كود فبا: تلوين كلمة معينة في الخلايا في إكسيل

Sub HighlightStrings()
    Dim xHStr As String, xStrTmp As String
    Dim xHStrLen As Long, xCount As Long, I As Long
    Dim xCell As Range
    Dim xArr
    On Error Resume Next
    xHStr = Application.InputBox("What is the string to highlight:", "KuTools For Excel", , , , , , 2)
    If TypeName(xHStr) <> "String" Then Exit Sub
    Application.ScreenUpdating = False
        xHStrLen = Len(xHStr)
        For Each xCell In Selection
            xArr = Split(xCell.Value, xHStr)
            xCount = UBound(xArr)
            If xCount > 0 Then
                xStrTmp = ""
                For I = 0 To xCount - 1
                    xStrTmp = xStrTmp & xArr(I)
                    xCell.Characters(Len(xStrTmp) + 1, xHStrLen).Font.ColorIndex = 3
                    xStrTmp = xStrTmp & xHStr
                Next
            End If
        Next
    Application.ScreenUpdating = True
End Sub

3. اضغط على F5 مفتاح لتشغيل الكود. وفي كوتولس ل إكسيل في مربع الحوار ، يرجى إدخال الكلمة المعينة التي ستبرزها في الخلايا ، ثم انقر فوق OK زر. انظر لقطة الشاشة:

بعد ذلك يمكنك رؤية جميع الكلمات التي حددتها ملونة باللون الأحمر في الخلايا المحددة على الفور كما هو موضح أدناه.


مقالات ذات صلة:

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

🤖 مساعد 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 (24)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Is there any chance that I can do both coloring and make words Bond with that VBA code? Please help me :)
This comment was minimized by the moderator on the site
Bonjour Cristal,
Merci pour ce code. Est-il possible de l'adapter pour mettre en évidence plusieurs mots "Apple,Rose,Vert,Merci"
Merci
This comment was minimized by the moderator on the site
Hi Cous,

The following VBA code can help. After running the code, you will get a dialog box. Please type in the words you want to highlight and separate them by comma.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/highlight.png
Sub HighlightStrings()
'Updated by Extendoffice 20230130
    Dim xHStr As String, xStrTmp As String
    Dim xHStrLen As Long, xCount As Long, I As Long
    Dim xCell As Range
    Dim xArr
    Dim xArr2
    On Error Resume Next
    xHStr = Application.InputBox("What is the string to highlight:", "KuTools For Excel", , , , , , 2)
    If TypeName(xHStr) <> "String" Then Exit Sub
    Application.ScreenUpdating = False
    
    xArr2 = Split(xHStr, ",")
    For j = 0 To UBound(xArr2)
        xHStr = xArr2(j)
    
        xHStrLen = Len(xHStr)
        For Each xCell In Selection
            xArr = Split(xCell.Value, xHStr)
            xCount = UBound(xArr)
            If xCount > 0 Then
                xStrTmp = ""
                For I = 0 To xCount - 1
                    xStrTmp = xStrTmp & xArr(I)
                    xCell.Characters(Len(xStrTmp) + 1, xHStrLen).Font.ColorIndex = 3
                    xStrTmp = xStrTmp & xHStr
                Next
            End If
        Next
    Next
    
    Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Thank you. that was really helpful. Can someone please tell how to color the text instead of highlighting it?

Regards
This comment was minimized by the moderator on the site
Hi Shaik Faiaz hamad,

Excel does not allow coloring a part of a cell. I'm sorry I can't help you with this problem.
This comment was minimized by the moderator on the site
Thank you that is very useful. How can I Highlight a word instead of a font color?

Regards.
This comment was minimized by the moderator on the site
how could the script be altered to do the following?

increase the font by 1 size, and
highlight multiple words with one running of the script?

Thx!
This comment was minimized by the moderator on the site
Hi t.taln,

If you want to increae the font size by 1 and highlight multiple words at the same time, please add the following line after the line "xCell.Characters(Len(xStrTmp) + 1, xHStrLen).Font.ColorIndex = 3" in the VBA code.
Note: You need to know the current font size of the selected cell beforehand, and then enter a number one size larger than the original word. The number 12 in the line below is the font size I will assign to the matching words. And the original font size of the word is 11.
xCell.Characters(Len(xStrTmp) + 1, xHStrLen).Font.Size = 12
This comment was minimized by the moderator on the site
That's very nice, thx! I'm wondering if anyone knows how to make it work on Mac? Many thanks
Rated 5 out of 5
This comment was minimized by the moderator on the site
Ciao,
a me servirebbe evidenziare tutti i numeri (comprensivi di due decimali) da -10,00 a 0 in rosso e da 0 a +10,00 in verde. come posso fare per non aggiungere singolarmente ogni dato senza aggiungerli tutti manualmente?

Grazie mille
This comment was minimized by the moderator on the site
Hi Ciao,
Are your numbers located in different cells in a range? If so, you can create two conditional formatting rules (between -10 and 0, between 0 and 10) to highlight these numbers. If not, can you upload a screenshot of your data?
This comment was minimized by the moderator on the site
Buna,

Coloreaza cuvantul doar daca e la inceput. Daca e la mijloc in aceeasi casuta de excel sau la sfarsit nu-l coloreaza.
Ce anume as putea schimba in cod pentru a-l colora indiferent unde se afla in casuta excel?

Multumesc!
This comment was minimized by the moderator on the site
Hi Andreea,
If you only want to highlight the word if it is at the beginning of the selected cells. The following VBA code can do you a favor. Please give it a try.
Sub HighlightStrings()
'Updated by Extendoffice 20220805
    Dim xHStr As String, xStrTmp As String
    Dim xHStrLen As Long, xCount As Long, I As Long
    Dim xCell As Range
    Dim xArr
    On Error Resume Next
    xHStr = Application.InputBox("What is the string to highlight:", "KuTools For Excel", , , , , , 2)
    If TypeName(xHStr) <> "String" Then Exit Sub
    Application.ScreenUpdating = False
        xHStrLen = Len(xHStr)
        For Each xCell In Selection
            If xHStrLen <= Len(xCell.Value) Then
                If xHStr = Left(xCell.Value, xHStrLen) Then
                    xCell.Characters(1, xHStrLen).Font.ColorIndex = 3
                End If
            End If
        Next
    Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Bonjour,
Est-il possible de supprimer la boite de dialogue et de mettre par défaut "apple" comme mot recherché ?
Merci
This comment was minimized by the moderator on the site
Hello PAUC,
The following code can do you a favor. Please give it a try.
Sub HighlightStrings()
'Updated by Extendoffice 20220721
    Dim xHStr As String, xStrTmp As String
    Dim xHStrLen As Long, xCount As Long, I As Long
    Dim xCell As Range
    Dim xArr
    On Error Resume Next
    xHStr = "apple"
    If TypeName(xHStr) <> "String" Then Exit Sub
    Application.ScreenUpdating = False
        xHStrLen = Len(xHStr)
        For Each xCell In Selection
            xArr = Split(xCell.Value, xHStr)
            xCount = UBound(xArr)
            If xCount > 0 Then
                xStrTmp = ""
                For I = 0 To xCount - 1
                    xStrTmp = xStrTmp & xArr(I)
                    xCell.Characters(Len(xStrTmp) + 1, xHStrLen).Font.ColorIndex = 3
                    xStrTmp = xStrTmp & xHStr
                Next
            End If
        Next
    Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Thanks... this was very helpful! Is there a way to adjust the macro so that it only highlights whole words instead of partials. For instance, I'm trying to highlight the word "design" but it highlights the "design" in the word "designate". I want it to skip over that word if it's not the whole word. Thanks!
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