- Katılım
- 18 Nisan 2008
- Mesajlar
- 1,105
- Excel Vers. ve Dili
- office2010
İkiTarihMizan sayfasında [C:N] aralığını listeler.
https://www.dosyaupload.com/54xo
Kod:
Private Sub CommandButton1_Click()
Z = TimeValue(Now)
Application.ScreenUpdating = False
Set s1 = Sheets("Yevmiye")
Set s2 = Sheets("İkiTarihMizan")
Set d = CreateObject("scripting.dictionary")
ss1 = s1.Cells(Rows.Count, 1).End(xlUp).Row
ss2 = s2.Cells(Rows.Count, 1).End(xlUp).Row
trh1 = CDate(s2.[A1])
trh2 = CDate(s2.[A2])
a = s1.Range("A2:U" & ss1)
ReDim b(1 To UBound(a), 1 To 12)
For i = 1 To UBound(a)
If a(i, 2) >= trh1 And a(i, 2) <= trh2 Then
veri = a(i, 4)
If Not d.exists(veri) Then
say = say + 1
d(a(i, 4)) = say
If Len(veri) >= 3 Then b(say, 1) = Left((veri), 3)
If Len(veri) >= 6 Then b(say, 2) = Left((veri), 6)
If Len(veri) >= 7 Then b(say, 3) = Left((veri), 7)
If Len(veri) >= 9 Then b(say, 4) = Left(veri, 9)
If Len(veri) >= 10 Then b(say, 5) = Left(veri, 10)
If Len(veri) >= 11 Then b(say, 6) = Left(veri, 11)
End If
sat = d(a(i, 4))
b(sat, 7) = b(sat, 7) + a(i, 7) ' Borç
b(sat, 8) = b(sat, 8) + a(i, 8) ' Alacak
b(sat, 9) = b(sat, 9) + a(i, 11) ' Doviz Borç
b(sat, 10) = b(sat, 10) + a(i, 12) ' Doviz Alacak
b(sat, 11) = b(sat, 11) + a(i, 16) ' T-U Borç
b(sat, 12) = b(sat, 12) + a(i, 17) ' T-U Alacak
End If
Next i
'****************************************************************
tbl = Array(b)
Erase b
d.RemoveAll
ReDim b(1 To say * 2, 1 To 7)
For i = 1 To say
For j = 1 To 6
veri = CStr(tbl(0)(i, j))
If Not IsEmpty(veri) Then
If Not d.exists(veri) Then
say1 = say1 + 1
d(veri) = say1
b(say1, 1) = CStr(veri)
End If
b(d(veri), 2) = b(d(veri), 2) + tbl(0)(i, 7) ' Borç
b(d(veri), 3) = b(d(veri), 3) + tbl(0)(i, 8) ' Alacak
b(d(veri), 4) = b(d(veri), 4) + tbl(0)(i, 9) ' Doviz Borç
b(d(veri), 5) = b(d(veri), 5) + tbl(0)(i, 10) ' Doviz Alacak
b(d(veri), 6) = b(d(veri), 6) + tbl(0)(i, 11) ' T-U Borç
b(d(veri), 7) = b(d(veri), 7) + tbl(0)(i, 12) ' T-U Alacak
End If
Next j
Next i
'****************************************************************
k = s2.Range("A4:A" & ss2)
On Error Resume Next
ReDim c(1 To UBound(k), 1 To 12)
For i = 1 To UBound(k)
n = n + 1
For y = 1 To 12: c(i, y) = 0: Next y
c(n, 1) = b(d(CStr(k(i, 1))), 2) 'Borç -C
c(n, 2) = b(d(CStr(k(i, 1))), 3) 'Alacak -D
If b(d(CStr(k(i, 1))), 2) > b(d(CStr(k(i, 1))), 3) Then
c(n, 3) = b(d(CStr(k(i, 1))), 2) - b(d(CStr(k(i, 1))), 3) 'Bakiye Borç -E
Else
c(n, 4) = b(d(CStr(k(i, 1))), 3) - b(d(CStr(k(i, 1))), 2) 'Bakiye Alacak -F
End If
c(n, 5) = b(d(CStr(k(i, 1))), 4) 'Döviz Borç -G
c(n, 6) = b(d(CStr(k(i, 1))), 5) 'Döviz Alacak -H
If b(d(CStr(k(i, 1))), 4) > b(d(CStr(k(i, 1))), 5) Then
c(n, 7) = b(d(CStr(k(i, 1))), 4) - b(d(CStr(k(i, 1))), 5) 'Dvz. Bakiye Borç -I
Else
c(n, 8) = b(d(CStr(k(i, 1))), 5) - b(d(CStr(k(i, 1))), 4) 'Dvz. Bakiye Alacak -J
End If
c(n, 9) = b(d(CStr(k(i, 1))), 6) 'T-U Borç -K
c(n, 10) = b(d(CStr(k(i, 1))), 7) 'T-U Alacak -L
If b(d(CStr(k(i, 1))), 6) > b(d(CStr(k(i, 1))), 7) Then
c(n, 11) = b(d(CStr(k(i, 1))), 6) - b(d(CStr(k(i, 1))), 7) 'T-U Brc Bky -M
Else
c(n, 12) = b(d(CStr(k(i, 1))), 7) - b(d(CStr(k(i, 1))), 6) 'T-U Alc Bky -N
End If
Next i
'*************************************************************************
s2.[C4].Resize(n, 12) = c
s2.[C4].Resize(n, 12).NumberFormat = "#,##0.00"
Application.ScreenUpdating = True
MsgBox CDate(TimeValue(Now) - Z)
End Sub
https://www.dosyaupload.com/54xo