Skip to main content

AccessTr.neT


A Sayfasında Olan Veri B Sayfasında Varsa A Sayfasındaki İlgili Satırı Silme

A Sayfasında Olan Veri B Sayfasında Varsa A Sayfasındaki İlgili Satırı Silme

#19
(19/11/2020, 01:46)feraz yazdı: Doğru anladımmı bilemiyorum. Deneyiniz.

Private Sub SayfayýHazýrla_Click()

Dim bul As Range, s1 As Worksheet, s2 As Worksheet, s3 As Worksheet
Dim arr(), i As Long, son As Long, dogru As Boolean, say As Long, soncomboSayfa As Long

If Len(Trim(Me.ComboBox1.Value)) = 0 Then
    MsgBox "Sayfa seciniz...", vbCritical, "Safa sec"
    Exit Sub
End If

Set s1 = ThisWorkbook.Sheets("VERÝ") 'Veri
Set s2 = ThisWorkbook.Sheets("KONTROL") 'Kontrol
Set s3 = ThisWorkbook.Sheets(Me.ComboBox1.Value)
son = s1.Cells(Rows.Count, 1).End(3).Row
soncomboSayfa = s3.Cells(Rows.Count, "Aj").End(3).Row
If soncomboSayfa < 7 Then soncomboSayfa = 7

If son < 2 Then GoTo son
ReDim arr(1 To son, 1 To 5)
say = 1
On Error Resume Next
s3.Range("A7:E" & soncomboSayfa).ClearContents
On Error GoTo 0
For i = 2 To son
    dogru = False
    Set bul = s2.Range("D:F").Find(s1.Cells(i, 2).Value, , , 1) 'Sicil
    If Not bul Is Nothing Then dogru = True
    Set bul = s2.Range("D:F").Find(s1.Cells(i, 3).Value, , , 1) 'ad
    If Not bul Is Nothing Then dogru = True
    Set bul = s2.Range("D:F").Find(s1.Cells(i, 4).Value, , , 1) 'soyad
    If Not bul Is Nothing Then dogru = True
    Set bul = s2.Range("D:F").Find(s1.Cells(i, 5).Value, , , 1) 'rütbe
    If Not bul Is Nothing Then dogru = True
    If dogru = False Then
        arr(say, 1) = say
        arr(say, 2) = s1.Cells(i, 2).Value
        arr(say, 3) = s1.Cells(i, 5).Value
        arr(say, 4) = s1.Cells(i, 3).Value
        arr(say, 5) = s1.Cells(i, 4).Value
        say = say + 1
    End If
Next
If say > 1 Then
    s3.Range("A7").Resize(say, UBound(arr, 2)).Value = arr
End If

son:
Set s1 = Nothing: Set s2 = Nothing: Set s3 = Nothing: Set bul = Nothing: Erase arr
MsgBox "Bitti", vbInformation, "Bitti"
End Sub
Mobilden yazıyorum.Bu koda göre 4 sütuna göre arıyor döngü kusmı.Eğer herhangi nirinde varsa işlem yapmıyır zaten.Yada ben tam anlayamadım olayı.
Öncedende dediğim gibi 1 ve toplam olayı kolay iş.hata almanızın sebebi sheet içinde sayfaad yazmıştım.Burayı böyle denediyseniz ondandır.Yada son diye değişken tanımlamayıp o değikenle son satır no buldurmadığınızdandır.
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
RE: A Sayfasında Olan Veri B Sayfasında Varsa A Sayfasındaki İlgili Satırı Silme - Yazar: feraz - 19/11/2020, 20:38
Task