اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

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

  • أفضل إجابة
قام بنشر
Sub Test()
    Dim a, w, ws As Worksheet, f As Boolean, i As Long, ii As Long, k As Long, m As Long
    Application.ScreenUpdating = False
        Set ws = ActiveSheet
        ws.Range("B20").CurrentRegion.Offset(2).ClearContents
        w = ws.Range("D20").Value
        If w = Empty Then MsgBox "Enter ID First", vbExclamation: Exit Sub
        a = ws.Range("A3:P" & ws.Cells(Rows.Count, 1).End(xlUp).Row).Value
        ReDim b(1 To UBound(a, 1) * 4, 1 To 5)
        For i = LBound(a) To UBound(a)
            If a(i, 4) = w Then
                k = k + 1
                b(k, 1) = a(i, 1)
                b(k, 2) = a(i, 2)
                m = 0
                For ii = 5 To 14 Step 3
                    If a(i, ii) <> Empty Then
                        f = True
                        b(k + m, 3) = a(i, ii)
                        b(k + m, 4) = a(i, ii + 1)
                        b(k + m, 5) = a(i, ii + 2)
                        m = m + 1
                    End If
                Next ii
                If m > 0 Then k = k + m - 1
                If f = False Then b(k, 1) = Empty: b(k, 2) = Empty: f = False: k = k - 1
            End If
        Next i
        If k > 0 Then ws.Range("B22").Resize(k, UBound(b, 2)).Value = b
    Application.ScreenUpdating = True
End Sub

 

  • Like 2
  • Thanks 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