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

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

قام بنشر

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

Public Sub FilterAndCopy()
    Dim OnRng As Range, n As Long, tmp As Long
    Dim WS As Worksheet: Set WS = Sheets("اجمالي4")
    Dim Sh1 As Worksheet: Set Sh1 = Sheets("بنون ناجحون")
    Dim Sh2 As Worksheet: Set Sh2 = Sheets("بنات ناجحون")
    
    tmp = 56
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

    Sh1.Range("A7:BD" & Sh1.Rows.Count).Clear
    Sh2.Range("A7:BD" & Sh2.Rows.Count).Clear

    With WS
        Set OnRng = .Range("A2:BD" & .Cells(.Rows.Count, "A").End(xlUp).Row)
    End With

    With OnRng
        n = WorksheetFunction.CountIfs(OnRng.Columns(9), "ذكر")
        If n <> 0 Then
            .AutoFilter Field:=9, Criteria1:="ذكر"
            .Offset(1, 0).Resize(.Rows.Count - 1, tmp).Copy Sh1.Range("A7")
        End If

        n = WorksheetFunction.CountIfs(OnRng.Columns(9), "انثى")
        If n <> 0 Then
            .AutoFilter Field:=9, Criteria1:="انثى"
            .Offset(1, 0).Resize(.Rows.Count - 1, tmp).Copy Sh2.Range("A7")
        End If

        .Parent.AutoFilterMode = False
    End With

    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
End Sub

 

ترحيل بنون ناجحون وترحيل بنات ناجحات.rar

  • Like 2

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.

×
×
  • اضف...

Important Information