LIKE operatörünün kullanımı

Katılım
20 Mart 2009
Mesajlar
333
Excel Vers. ve Dili
office 2003 ingilizce
Sub AL_sil()
Dim sat As Long
Sheets("Yurtdışı").Range("BS1") = WorksheetFunction.CountA(Sheets("Yurtdışı").Range("C2:C65536"))
If MsgBox("" & Sheets("Yurtdışı").Range("BS1") & " İptal İşlemi Silinecek !", vbQuestion + vbYesNo, Application.UserName) = vbYes Then
For sat = Cells(Rows.Count, "C").End(xlUp).Row To 2 Step -1
If Len(Trim(Cells(sat, "C"))) Like "*AL*" Then Rows(sat).Delete
Next
End If
Sheets("Yurtdışı").Range("BS1") = ""

Like operatörünü bu şekilde kullanarak kayıt silmek istiyorum ancak bana toplam row sayısını döndürüyor. Nerede hata yapıyorum acaba? Yani msgboz ta 137 diyeceğine 7300 diyor.
 

Ömer

Moderatör
Yönetici
Katılım
18 Ağustos 2007
Mesajlar
22,184
Excel Vers. ve Dili
Microsoft 365 Tr
Ofis 2016 Tr
Merhaba,

Len(Trim(Cells(sat, "C"))) Like "*AL*"

Uzunluk ile aranan değer "*AL*" arasında bir bağlantı kuramadım.

.
 
Katılım
20 Mart 2009
Mesajlar
333
Excel Vers. ve Dili
office 2003 ingilizce
Bu silme işlemi için çalışıyor
Sub sil()
Dim sat As Long
Sheets("Yurtdışı").Range("BS1") = WorksheetFunction.CountA(Sheets("Yurtdışı").Range("BL2:BL65536"))
If MsgBox("" & Sheets("Yurtdışı").Range("BS1") & " İptal İşlemi Silinecek !", vbQuestion + vbYesNo, Application.UserName) = vbYes Then
For sat = Cells(Rows.Count, "BL").End(xlUp).Row To 2 Step -1
If Len(Trim(Cells(sat, "BL"))) > 0 Then Rows(sat).Delete
Next
End If
Sheets("Yurtdışı").Range("BS1") = ""

ama like kullanınca beceremedim
hatta bu kısmı
If Cells(sat, "BL") like "*AL*" Then Rows(sat).Delete şeklinde de denedim. ama 50 kayıt silinecek yerine 7500 gibi bir rakam döndürüyor
 

Ömer

Moderatör
Yönetici
Katılım
18 Ağustos 2007
Mesajlar
22,184
Excel Vers. ve Dili
Microsoft 365 Tr
Ofis 2016 Tr
Hangi aralıkta hangi şart sağlanınca satır silinecek?

.
 
Katılım
20 Mart 2009
Mesajlar
333
Excel Vers. ve Dili
office 2003 ingilizce
Toplam 7313 kayıt var. C sütünunda içinde AL geçen satırları silmeye çalışıyorum
 

Ömer

Moderatör
Yönetici
Katılım
18 Ağustos 2007
Mesajlar
22,184
Excel Vers. ve Dili
Microsoft 365 Tr
Ofis 2016 Tr
Toplam 7313 kayıt var. C sütünunda içinde AL geçen satırları silmeye çalışıyorum
Bu şekilde deneyiniz.

Kod:
Sub Sil()
 
Dim i As Long
 
For i = Cells(Rows.Count, "[B][COLOR=red]C[/COLOR][/B]").End(xlUp).Row To 2 Step -1
    If Cells(i, "[COLOR=red][B]C[/B][/COLOR]") Like "*[COLOR=blue][B]AL[/B][/COLOR]*" Then
        Rows(i).Delete
    End If
Next i
End Sub
.
 
Katılım
20 Mart 2009
Mesajlar
333
Excel Vers. ve Dili
office 2003 ingilizce
Teşekkürler.
If MsgBox("" & Sheets("Yurtdışı").Range("BS1") & " İptal İşlemi Silinecek !", vbQuestion + vbYesNo, Application.UserName) = vbYes Then
Bu kısmı nasıl yapabilirim? Yani silinen kayıt saysından emin olmak için
 

Ömer

Moderatör
Yönetici
Katılım
18 Ağustos 2007
Mesajlar
22,184
Excel Vers. ve Dili
Microsoft 365 Tr
Ofis 2016 Tr
Bu şekilde deneyiniz..

Kod:
Sub Sil()
 
Dim i As Long, say As Long
 
say = WorksheetFunction.CountIf([C:C], "*AL*")
 
If MsgBox(say & " İptal İşlemi Silinecek !", vbQuestion + vbYesNo, _
            Application.UserName) = vbYes Then
     
    For i = Cells(Rows.Count, "C").End(xlUp).Row To 2 Step -1
        If Cells(i, "C") Like "*AL*" Then
            Rows(i).Delete
        End If
    Next i
End If
 
End Sub
.
 
Katılım
20 Mart 2009
Mesajlar
333
Excel Vers. ve Dili
office 2003 ingilizce
Çok teşekkürler kolay gelsin
 
Üst