- Katılım
- 5 Eylül 2007
- Mesajlar
- 1,247
- Excel Vers. ve Dili
- ofis 2010
iyi günler; kullanmakta olduğum kod' ta işlemde eşleşen değerleri tespit edip eşleşen sayfasına aktarıyor, aynı anda eşleşmeyenleri de tespit edip eşleşmeyenler sayfasına aktarması da gerekiyor. deneme yaptım ama sonuç alamadım Teşekkürler.
Kod:
Sub işlem()
Application.ScreenUpdating = False
On Error Resume Next
Call analiz
Call sayfaya_gönder
Application.ScreenUpdating = True
End Sub
Sub analiz()
Application.ScreenUpdating = False
On Error Resume Next
Sheets("MASTER").Range("f2:ı65536").ClearContents
'Sheets("MASTER").Range("a2:e65536").Interior.ColorIndex = xlNone
Set s1 = ThisWorkbook.Worksheets("MASTER")
For i = 2 To s1.Range("A65536").End(xlUp).Row
If s1.Cells(i, "c") <> "" Then s1.Cells(i, "f") = s1.Cells(i, "a") & "_" & s1.Cells(i, "c")
If s1.Cells(i, "d") <> "" Then s1.Cells(i, "g") = s1.Cells(i, "a") & "_" & Abs(s1.Cells(i, "d"))
Next i
sonn = s1.Range("a65536").End(xlUp).Row
For i = 2 To sonn
For k = 2 To sonn
If s1.Cells(i, "f") <> "" And WorksheetFunction.CountIf(s1.Range("g2:g" & k), s1.Cells(i, "f")) = 1 And s1.Cells(i, "h") = "" Then
s1.Cells(i, "h") = s1.Cells(i, "f") & WorksheetFunction.CountIf(s1.Range("f2:f" & i), s1.Cells(i, "f"))
End If
Next k
Next i
For i = 2 To sonn
For k = 2 To sonn
If s1.Cells(i, "g") <> "" And WorksheetFunction.CountIf(s1.Range("f2:f" & k), s1.Cells(i, "g")) = 1 And s1.Cells(i, "ı") = "" Then
s1.Cells(i, "ı") = s1.Cells(i, "g") & WorksheetFunction.CountIf(s1.Range("g2:g" & i), s1.Cells(i, "g"))
End If
Next k
Next i
Application.ScreenUpdating = True
End Sub
Sub sayfaya_gönder()
Application.ScreenUpdating = False
On Error Resume Next
Set s1 = ThisWorkbook.Worksheets("MASTER")
Set s2 = ThisWorkbook.Worksheets("eşleşenler")
say = 0
For i = 2 To s1.Range("h65536").End(xlUp).Row
For k = 2 To s1.Range("ı65536").End(xlUp).Row
If s1.Cells(i, "j") = "" And s1.Cells(i, "h") <> "" And s1.Cells(i, "h") = s1.Cells(k, "ı") Then
sonsatir = s2.Range("A65536").End(xlUp).Row + 1
s2.Cells(sonsatir, 1) = s1.Cells(i, 1)
s2.Cells(sonsatir, 2) = s1.Cells(i, 2)
s2.Cells(sonsatir, 3) = s1.Cells(i, 3)
s2.Cells(sonsatir, 4) = s1.Cells(i, 4)
s2.Cells(sonsatir, 5) = s1.Cells(i, 5)
s2.Range("a" & sonsatir & ":e" & sonsatir).Interior.ColorIndex = s1.Cells(1, "c").Interior.ColorIndex
s1.Cells(i, "j") = 1
s1.Range("a" & i & ":e" & i).Interior.ColorIndex = s1.Cells(1, "c").Interior.ColorIndex
s2.Cells(sonsatir, 6) = s1.Cells(k, 1)
s2.Cells(sonsatir, 7) = s1.Cells(k, 2)
s2.Cells(sonsatir, 8) = s1.Cells(k, 3)
s2.Cells(sonsatir, 9) = s1.Cells(k, 4)
s2.Cells(sonsatir, 10) = s1.Cells(k, 5)
say = say + 1
s1.Range("a" & k & ":e" & k).Interior.ColorIndex = s1.Cells(1, "d").Interior.ColorIndex
s2.Range("f" & sonsatir & ":j" & sonsatir).Interior.ColorIndex = s1.Cells(1, "d").Interior.ColorIndex
End If
Next k
Next i
Application.ScreenUpdating = True
If say >= 1 Then MsgBox (say & " Adet eşleşen veri sayfalara gönderildi.")
If say = 0 Then MsgBox ("Sayfalara tasniflenecek veri BULUNAMADI."), vbCritical
End Sub
Sub işlemleri_temizle()
Sheets("MASTER").Range("f2:j65536").ClearContents
Sheets("MASTER").Range("a2:e65536").Interior.ColorIndex = xlNone
Sheets("eşleşenler").Range("a2:j65536").ClearContents
Sheets("eşleşenler").Range("a2:j65536").Interior.ColorIndex = xlNone
End Sub
