- Katılım
- 18 Ocak 2008
- Mesajlar
- 12,878
- Excel Vers. ve Dili
- 2003 excell türkçe
ve
2007 excell türkçe
kod:
Kod:
Sub verial()
Dim baslangıc, bitis, aranan1, bulunan1, bulunan2
baslangıc = Sheets("ekstre").Cells(1, "b").Value
bitis = Sheets("ekstre").Cells(1, "d").Value
aranan1 = Sheets("ekstre").Cells(2, "b").Value
Sheets("ekstre").Range("A4:e" & Rows.Count).ClearContents
If IsDate(baslangıc) <> True Then Exit Sub
If IsDate(bitis) <> True Then Exit Sub
sat = 4
say1 = 0
say2 = 0
For j = 2 To Sheets("veri").Cells(Rows.Count, "A").End(xlUp).Row
If CDate(baslangıc) > CDate(Sheets("veri").Cells(j, "A").Value) Then
bulunan1 = Sheets("veri").Cells(j, "b").Value
bulunan2 = Sheets("veri").Cells(j, "c").Value
If bulunan1 = aranan1 Then
say1 = say1 + CDbl(Sheets("veri").Cells(j, "e").Value)
veri1 = CDbl(Sheets("veri").Cells(j, "a").Value)
End If
If bulunan2 = aranan1 Then
say2 = say2 + CDbl(Sheets("veri").Cells(j, "f").Value)
veri2 = Sheets("veri").Cells(j, "d").Value
End If
End If
Next
Sheets("ekstre").Cells(sat, "a").Value = veri1
Sheets("ekstre").Cells(sat, "b").Value = "devir"
Sheets("ekstre").Cells(sat, "c").Value = say1
Sheets("ekstre").Cells(sat, "d").Value = say2
Sheets("ekstre").Cells(sat, "e").Value = say1 - say2
'Sheets("ekstre").Cells(sat, "e").Value = "=RC[-2]-RC[-1]"
sat = sat + 1
For i = 2 To Sheets("veri").Cells(Rows.Count, "A").End(xlUp).Row
bulunan1 = Sheets("veri").Cells(i, "b").Value
bulunan2 = Sheets("veri").Cells(i, "c").Value
If CDate(baslangıc) <= CDate(Sheets("veri").Cells(i, "A").Value) _
And CDate(bitis) >= CDate(Sheets("veri").Cells(i, "A").Value) Then
If bulunan1 = aranan1 Then
Sheets("ekstre").Cells(sat, "a").Value = Sheets("veri").Cells(i, "A").Value
Sheets("ekstre").Cells(sat, "b").Value = Sheets("veri").Cells(i, "d").Value
Sheets("ekstre").Cells(sat, "c").Value = Sheets("veri").Cells(i, "f").Value
'Sheets("ekstre").Cells(sat, "e").Value = Sheets("ekstre").Cells(sat - 1, "e").Value - Sheets("ekstre").Cells(sat, "d").Value
Sheets("ekstre").Cells(sat, "e").Value = "=R[-1]C+RC[-2]-RC[-1]"
sat = sat + 1
End If
If bulunan2 = aranan1 Then
Sheets("ekstre").Cells(sat, "a").Value = Sheets("veri").Cells(i, "A").Value
Sheets("ekstre").Cells(sat, "b").Value = Sheets("veri").Cells(i, "d").Value
Sheets("ekstre").Cells(sat, "d").Value = Sheets("veri").Cells(i, "f").Value
Sheets("ekstre").Cells(sat, "e").Value = "=R[-1]C+RC[-2]-RC[-1]"
'Sheets("ekstre").Cells(sat, "e").Value = Sheets("ekstre").Cells(sat - 1, "e").Value - Sheets("ekstre").Cells(sat, "d").Value
sat = sat + 1
End If
End If
Next
MsgBox "işlem tamam"
End Sub
