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

تعديل كود


إذهب إلى أفضل إجابة Solved by أ / محمد صالح,

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

اخواني الكرام 

لدي الكود التالي وهو خاص بالبحث في كل اوراق العمل حاولت اصلاحه ليبحث فقط في صفحات محددة كأن يبحث في الشيت الثالث والرابع والخامس والسادس ويترك البحث في باقي الشيتات ... ارجو المساعدة ... وكتب الله اجوركم

الملف كبير جدا ويتكون من اكثر من 30 شيت ونحن لدينا نت ضعيف جدا في اليمن 

والكود لا يحتاج سوى اسنثناء لبعض الصفحات من البحث

شكرا لك

 

Private Sub TextBox19_Change()
    TextBox1.Value = ""
    TextBox2.Value = ""
    TextBox3.Value = ""
    TextBox4.Value = ""
    TextBox5.Value = ""
    TextBox6.Value = ""
    TextBox7.Value = ""
    TextBox8.Value = ""
    TextBox9.Value = ""
    TextBox10.Value = ""
    TextBox11.Value = ""
    TextBox12.Value = ""
    TextBox13.Value = ""
    TextBox14.Value = ""
    TextBox15.Value = ""
    TextBox16.Value = ""
    TextBox17.Value = ""
    TextBox18.Value = ""
Dim x As Worksheet
         ListBox1.Clear
    k = 0
For Each x In ThisWorkbook.Worksheets
        ss = x.Cells(Rows.Count, 2).End(xlUp).Row
        For Each C In x.Range("c3:c" & ss)
            b = InStr(C, TextBox19)
            If b > 0 Then
                ListBox1.AddItem
                ListBox1.List(k, 0) = x.Cells(C.Row, 1).Value
                ListBox1.List(k, 1) = x.Cells(C.Row, 2).Value
                ListBox1.List(k, 2) = x.Cells(C.Row, 3).Value
                ListBox1.List(k, 3) = x.Cells(C.Row, 4).Value
                ListBox1.List(k, 4) = x.Cells(C.Row, 5).Value
                ListBox1.List(k, 5) = x.Cells(C.Row, 6).Value
                ListBox1.List(k, 6) = x.Cells(C.Row, 7).Value
                ListBox1.List(k, 7) = x.Cells(C.Row, 8).Value
                ListBox1.List(k, 😎 = x.Cells(C.Row, 9).Value
                ListBox1.List(k, 9) = x.Cells(C.Row, 10).Value
                ListBox1.List(k, 10) = x.Cells(C.Row, 11).Value
                ListBox1.List(k, 11) = x.Cells(C.Row, 12).Value
                ListBox1.List(k, 12) = x.Cells(C.Row, 13).Value
                ListBox1.List(k, 13) = x.Cells(C.Row, 14).Value
                ListBox1.List(k, 14) = x.Cells(C.Row, 15).Value
                ListBox1.List(k, 15) = x.Cells(C.Row, 16).Value
                ListBox1.List(k, 16) = x.Cells(C.Row, 17).Value
                ListBox1.List(k, 17) = x.Cells(C.Row, 18).Value
                                k = k + 1
            End If
        Next C
Next x
End Sub

 

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

  • أفضل إجابة

يمكنك استعمال هذا الشرط

ضع في المصفوفة shArr اسماء الشيتات التي ترغب البحث فيها

وغير كود for each x الى 

shArr = array("sheet1","sheet2","sheet3")
For Each x In ThisWorkbook.Worksheets
if UBound(Filter(shArr, x.name)) > -1 then
        ss = x.Cells(Rows.Count, 2).End(xlUp).Row
        For Each C In x.Range("c3:c" & ss)
            b = InStr(C, TextBox19)
            If b > 0 Then
                ListBox1.AddItem
                ListBox1.List(k, 0) = x.Cells(C.Row, 1).Value
                ListBox1.List(k, 1) = x.Cells(C.Row, 2).Value
                ListBox1.List(k, 2) = x.Cells(C.Row, 3).Value
                ListBox1.List(k, 3) = x.Cells(C.Row, 4).Value
                ListBox1.List(k, 4) = x.Cells(C.Row, 5).Value
                ListBox1.List(k, 5) = x.Cells(C.Row, 6).Value
                ListBox1.List(k, 6) = x.Cells(C.Row, 7).Value
                ListBox1.List(k, 7) = x.Cells(C.Row, 8).Value
                ListBox1.List(k, 8) = x.Cells(C.Row, 9).Value
                ListBox1.List(k, 9) = x.Cells(C.Row, 10).Value
                ListBox1.List(k, 10) = x.Cells(C.Row, 11).Value
                ListBox1.List(k, 11) = x.Cells(C.Row, 12).Value
                ListBox1.List(k, 12) = x.Cells(C.Row, 13).Value
                ListBox1.List(k, 13) = x.Cells(C.Row, 14).Value
                ListBox1.List(k, 14) = x.Cells(C.Row, 15).Value
                ListBox1.List(k, 15) = x.Cells(C.Row, 16).Value
                ListBox1.List(k, 16) = x.Cells(C.Row, 17).Value
                ListBox1.List(k, 17) = x.Cells(C.Row, 18).Value
                                k = k + 1
            End If
        Next C
end if
Next x

بالتوفيق 

  • Like 1
  • Thanks 1
رابط هذا التعليق
شارك

شكرا جزيلا استاذ محمد

وبارك الله فيك 

وجعل الله ذلك في ميزان حسناتك 

والله يزيد في الرجال من امثالك

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

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