اذهب الي المحتوي
أوفيسنا

مساعدة في حذف جزء من النص


إذهب إلى أفضل إجابة Solved by abouelhassan,

الردود الموصى بها

السلام عليكم 

لدي حقل اجتاج طريقة للابقاء على اول كلمة فقط  من كل خلية موجودة في الحقل مثلا  book rem   تصيح في الخلية book  وهكذا بقية الخلايا 

library.xlsx

تم تعديل بواسطه ازهر عبد العزيز
رابط هذا التعليق
شارك

جرب


Sub KeepFirstWordOnly()
    Dim cell As Range
    Dim words() As String
    Dim i As Integer
    
    For Each cell In Range("A1:A10") ' تغيير النطاق حسب الحاجة
        words = Split(cell.Value, " ")
        cell.Value = words(0)
    Next cell
End Sub

 

هذا الكود يفترض أن الكلمات مفصولة بمسافة. إذا كانت الكلمات مفصولة بفاصلة أو حرف آخر، يجب تغيير الجزء `Split(cell.Value, " ")` ليناسب الفاصلة الصحيحة، على سبيل المثال، `Split(cell.Value, ",")` للكلمات المفصولة بفاصلة.

رابط هذا التعليق
شارك

  • أفضل إجابة

تعديل


Sub KeepFirstWordOnly()
    Dim cell As Range
    Dim words() As String
    Dim i As Integer
    
    For Each cell In Range("A1:A10") ' تغيير النطاق حسب الحاجة
        words = Split(cell.Value, " ")
        If UBound(words) >= 0 Then ' التحقق من أن المصفوفة غير فارغة
            cell.Value = words(0)
        Else
            cell.Value = ""
        End If
    Next cell
End Sub

 

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information