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

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

قام بنشر

وعليكم السلام ورحمه الله وبركاته

تفضل

Option Explicit

Sub Sucess_Fail()
    Dim WSData As Worksheet, WSSucess As Worksheet, WSFail As Worksheet, arr As Variant
    Dim i As Long, J As Long, P As Long, PP As Long, LR As Long, StateRng As Range, State1 As Long, State2 As Long
    
    Set WSData = ThisWorkbook.Worksheets("شيت")
    Set WSSucess = ThisWorkbook.Worksheets("ناجح")
    Set WSFail = ThisWorkbook.Worksheets("دور ثان")
    LR = Application.Max(3, WSData.Cells(Rows.Count, "B").End(xlUp).Row)
    arr = WSData.Range("A3:P" & LR).Value
    Set StateRng = WSData.Range("P2" & ":P" & LR)
    WSSucess.Range("A5:O" & Application.Max(5, WSSucess.Cells(Rows.Count, "B").End(xlUp).Row)).ClearContents
    WSFail.Range("A5:O" & Application.Max(5, WSFail.Cells(Rows.Count, "B").End(xlUp).Row)).ClearContents
    
    State1 = WorksheetFunction.CountIf(StateRng, "ناجح")
    State2 = WorksheetFunction.CountIf(StateRng, "دور ثان")
    P = 1
    PP = 1
    
    ReDim Sucess(1 To State1, 1 To UBound(arr, 2) - 1)
    ReDim Fail(1 To State2, 1 To UBound(arr, 2) - 1)
    
    For i = 1 To UBound(arr, 1)
        For J = 2 To UBound(arr, 2) - 1
            If arr(i, 16) = "ناجح" Then
                Sucess(P, 1) = P
                Sucess(P, J) = arr(i, J)
                If J = 15 Then P = P + 1
            ElseIf arr(i, 16) = "دور ثان" Then
                Fail(PP, 1) = PP
                Fail(PP, J) = arr(i, J)
                If J = 15 Then PP = PP + 1
            End If
        Next J
    Next i
    
    If P > 0 Then WSSucess.Range("A5").Resize(P - 1, UBound(Sucess, 2)).Value = Sucess
    If PP > 0 Then WSFail.Range("A5").Resize(PP - 1, UBound(Fail, 2)).Value = Fail

End Sub

 

Sucess_Fail.xlsm

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