Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://excel-egy.com/forum/t4327
- ---------------------------------
- Sub Extract_Account_Statement_Between_Two_Dates_Arrays()
- Dim a, ws As Worksheet, sh As Worksheet, lr As Long, i As Long, k As Long
- Application.ScreenUpdating = False
- Set ws = ThisWorkbook.Worksheets("data")
- Set sh = ThisWorkbook.Worksheets("كشف حساب")
- lr = ws.ListObjects(1).ListColumns(2).DataBodyRange.Find(What:="*", SearchDirection:=xlPrevious).Row
- a = ws.Range("B5:H" & lr).Value
- ReDim b(1 To UBound(a, 1), 1 To 7)
- sh.Range("A9:H1020").ClearContents
- For i = 1 To UBound(a, 1)
- If a(i, 1) >= sh.Range("C3").Value And a(i, 1) <= sh.Range("G3").Value And a(i, 2) = sh.Range("E5").Value Then
- k = k + 1
- b(k, 1) = a(i, 1)
- b(k, 2) = a(i, 6)
- b(k, 3) = a(i, 7)
- b(k, 4) = a(i, 4)
- b(k, 5) = a(i, 5)
- b(k, 6) = "=IF(B" & k + 8 & "="""","""",IF(SUM($E$9:E" & k + 8 & ")-SUM($F$9:F" & k + 8 & ")>0,SUM($E$9:E" & k + 8 & ")-SUM($F$9:F" & k + 8 & "),0))"
- b(k, 7) = "=IF(B" & k + 8 & "="""","""",IF(SUM($F$9:F" & k + 8 & ")-SUM($E$9:E" & k + 8 & ")>0,SUM($F$9:F" & k + 8 & ")-SUM($E$9:E" & k + 8 & "),0))"
- End If
- Next i
- If k > 0 Then
- With sh
- .Range("B9").Resize(k, UBound(b, 2)).Value = b
- .Range("G9").Resize(k, 2).Value = .Range("G9").Resize(k, 2).Value
- End With
- End If
- Application.ScreenUpdating = True
- End Sub
Add Comment
Please, Sign In to add comment