- Katılım
- 8 Mart 2009
- Mesajlar
- 504
- Excel Vers. ve Dili
- 2010
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Makro ile sayfalar arası toplama ve çıkarma.
ayrıca sonuç sayfasının NOSUNA yazdığım ürün GİREN sayfasında yoksa uyarı verebilirmi.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ts
Set ts = Sheets("GİREN")
On Error GoTo Son
If Intersect(Target, Range("B4:B" & Rows.Count)) Is Nothing Then Exit Sub
If Target <> "" Then
If WorksheetFunction.CountIf(ts.Range("B4:B" & Rows.Count), Target) < 1 Then
MsgBox "Bu kayıt daha önce girilmiştir !", vbCritical, "Hata"
Target.ClearContents
Target.Select
Exit Sub
End If
End If
Son:
End Sub
Option Explicit
Sub toplayalım()
Dim ts, trabzonspor, hamsi As Date
Dim s1, s2, s3
Set s1 = Sheets("GİREN")
Set s2 = Sheets("ÇIKAN")
Set s3 = Sheets("SONUÇ")
For ts = 4 To s3.Cells(Rows.Count, "B").End(xlUp).Row
s3.Cells(ts, "C") = WorksheetFunction.VLookup(s3.Cells(ts, "B"), _
s1.Range("B:D"), 2, 0)
s3.Cells(ts, "H") = WorksheetFunction.VLookup(s3.Cells(ts, "B"), _
s1.Range("B:D"), 2, 0)
s3.Cells(ts, "N") = s3.Cells(ts, "C")
s3.Cells(ts, "D") = WorksheetFunction.VLookup(s3.Cells(ts, "B"), _
s1.Range("B:D"), 3, 0)
s3.Cells(ts, "I") = WorksheetFunction.VLookup(s3.Cells(ts, "B"), _
s1.Range("B:D"), 3, 0)
s3.Cells(ts, "O") = s3.Cells(ts, "D")
s3.Cells(ts, "E") = WorksheetFunction.SumIf(s1.Range("B:B"), s3. _
Cells(ts, "B"), s1.Range("E:E"))
s3.Cells(ts, "J") = WorksheetFunction.SumIf(s2.Range("B:B"), s3. _
Cells(ts, "B"), s2.Range("E:E"))
s3.Cells(ts, "P") = s3.Cells(ts, "E") - s3.Cells(ts, "J")
s3.Cells(ts, "F") = WorksheetFunction.SumIf(s1.Range("B:B"), s3. _
Cells(ts, "B"), s1.Range("F:F"))
s3.Cells(ts, "K") = WorksheetFunction.SumIf(s2.Range("B:B"), s3. _
Cells(ts, "B"), s2.Range("F:F"))
s3.Cells(ts, "Q") = s3.Cells(ts, "F") - s3.Cells(ts, "K")
Next
End Sub
İhsan bey, SONUÇ sayfasında kalan kısmında ürünleri topluyor, çıkarma işlemi yapmıyor.
düzelttim herhalde makrodaki (+) işaretini (-) yapınca çıkarma işlemini yaptı teşekkürler, kolay gelsin.
İhsan bey, kusara bakmassanız ben sizin yaptığınız makroları dosyama uyarlayamadım, ancak göndermiş olduğum dosyaya uyarladım normal çılışıyor, kendi orjinal dosyada sütunların yerleri farklı olduğu için uyarlayamadım yardımcı olurmusunuz, tekrar kusura bakmayın.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ts
Set ts = Sheets("GİREN")
On Error GoTo Son
If Intersect(Target, Range("B4:B" & Rows.Count)) Is Nothing Then Exit Sub
If Target <> "" Then
If WorksheetFunction.CountIf(ts.Range("G4:G" & Rows.Count), Target) < 1 Then
MsgBox "Bu kayıt daha önce girilmiştir !", vbCritical, "Hata"
Target.ClearContents
Target.Select
Exit Sub
End If
End If
Son:
End Sub
Option Explicit
Sub toplayalım()
Dim ts, trabzonspor, hamsi As Date
Dim s1, s2, s3
Set s1 = Sheets("GİREN")
Set s2 = Sheets("ÇIKAN")
Set s3 = Sheets("SONUÇ")
trabzonspor = MsgBox("Sonuçları Topluyorum", vbYesNo, "Onay")
If trabzonspor = vbNo Then Exit Sub
Application.ScreenUpdating = False
hamsi = Time
For ts = 3 To s3.Cells(Rows.Count, "B").End(xlUp).Row
s3.Cells(ts, "C") = WorksheetFunction.VLookup(s3.Cells(ts, "B"), _
s1.Range("G:I"), 2, 0)
s3.Cells(ts, "D") = WorksheetFunction.VLookup(s3.Cells(ts, "B"), _
s1.Range("G:I"), 3, 0)
s3.Cells(ts, "I") = WorksheetFunction.VLookup(s3.Cells(ts, "B"), _
s1.Range("G:I"), 3, 0)
s3.Cells(ts, "O") = s3.Cells(ts, "D")
s3.Cells(ts, "E") = WorksheetFunction.SumIf(s1.Range("G:G"), s3.Cells _
(ts, "B"), s1.Range("J:J"))
s3.Cells(ts, "J") = WorksheetFunction.SumIf(s2.Range("G:G"), s3.Cells _
(ts, "B"), s2.Range("J:J"))
s3.Cells(ts, "P") = s3.Cells(ts, "E") - s3.Cells(ts, "J")
s3.Cells(ts, "F") = WorksheetFunction.SumIf(s1.Range("G:G"), s3.Cells _
(ts, "B"), s1.Range("K:K"))
s3.Cells(ts, "K") = WorksheetFunction.SumIf(s2.Range("G:G"), s3.Cells _
(ts, "B"), s2.Range("K:K"))
s3.Cells(ts, "Q") = s3.Cells(ts, "F") - s3.Cells(ts, "K")
s3.Cells(ts, "G") = WorksheetFunction.SumIf(s1.Range("G:G"), s3.Cells _
(ts, "B"), s1.Range("L:L"))
s3.Cells(ts, "L") = WorksheetFunction.SumIf(s2.Range("G:G"), s3.Cells _
(ts, "B"), s2.Range("L:L"))
s3.Cells(ts, "R") = s3.Cells(ts, "G") - s3.Cells(ts, "L")
Next
Application.ScreenUpdating = True
MsgBox Format(hamsi - Time, "hh:mm:ss") & vbLf _
& "Sürede Toplamları Çıkardım", , "Bitiş"
End Sub
İhsan bey ellerinize sağlık, teşekkürler. Kolay gelsin.