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

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

  • أفضل إجابة
قام بنشر
Sub Test()
    Dim a, ws As Worksheet, sh As Worksheet, r As Range, txt As String, i As Long
    Set ws = ThisWorkbook.Worksheets(1)
    Set sh = ThisWorkbook.Worksheets(2)
    sh.Range("A3:C" & Rows.Count).ClearContents
    Set r = ws.Range("F2:M" & ws.Cells(Rows.Count, "F").End(xlUp).Row)
    a = r.Value
    With CreateObject("Scripting.Dictionary")
        For i = 1 To UBound(a, 1)
            If a(i, 8) = sh.Range("A1").Value Then
                txt = Join(Array(a(i, 2), a(i, 3)), Chr(2))
                If Not .Exists(txt) Then
                    .Item(txt) = .Count + 1
                    a(.Count, 1) = a(i, 2)
                    a(.Count, 2) = a(i, 3)
                    a(.Count, 3) = Evaluate("SUMIFS('" & ws.Name & "'!" & r.Columns(4).Address & ",'" & ws.Name & "'!" & r.Columns(1).Address & ","">=""&" & "'" & sh.Name & "'!" & Range("C1").Address & ", '" & ws.Name & "'!" & r.Columns(1).Address & ",""<="" &" & "'" & sh.Name & "'!" & Range("D1").Address & ",'" & ws.Name & "'!" & r.Columns(2).Address & "," & Chr(34) & a(.Count, 1) & Chr(34) & ",'" & ws.Name & "'!" & r.Columns(3).Address & "," & Chr(34) & a(.Count, 2) & Chr(34) & ")")
                End If
            End If
        Next i
        i = .Count
    End With
    sh.Range("A3").Resize(i, 3).Value = a
End Sub

 

  • 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.

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

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

Important Information