Skip to main content

AccessTr.neT


Excel Vba İle Userform Üzerinden Kayıt Silme Hakkında.

Oğuz Türkyılmaz
Oğuz Türkyılmaz
27
2316

Excel Vba İle Userform Üzerinden Kayıt Silme Hakkında.

#21
Buda alternatif olsun dictionary ve dizi ile Img-grin

Private Sub btn_KayitSil_Click()
    Dim dic As Object, i As Long
    Dim dizi, sonTabloSatr As Long, aranan
   
    If Len(Trim(TextBox_ID.Value)) = 0 Then Exit Sub
    If Len(Trim(ComboBox_FirmaUnvani.Value)) = 0 Then Exit Sub
    If MsgBox("Veriler Silinecek, Emin misiniz...?", vbExclamation + vbYesNo, "Firma Tanýmlama Formu") = vbNo Then Exit Sub

    With ThisWorkbook.Worksheets("Ana_Sayfa")
        sonTabloSatr = .Cells.Find("*", _
                                    SearchOrder:=xlByRows, LookIn:=xlValues, SearchDirection:=xlPrevious).Row
   
        If WorksheetFunction.CountA(.Range("A2:A" & Rows.Count)) = 0 Then Exit Sub
        If sonTabloSatr < 2 Then Exit Sub
        Set dic = CreateObject("scripting.dictionary")
        If WorksheetFunction.CountA(.Range("A2:A" & Rows.Count)) = 1 Then
            dic.Add CStr(.Range("A" & sonTabloSatr).Value), 2
        ElseIf WorksheetFunction.CountA(.Range("A2:A" & Rows.Count)) > 1 Then
            dizi = .Range("A2:A" & sonTabloSatr).Value
            For i = LBound(dizi) To UBound(dizi)
                aranan = CStr(dizi(i, 1))
                If dic.Exists(aranan) = False Then dic.Add aranan, i + 1
            Next
            Erase dizi
        End If
       
        If dic.Count = 0 Then Exit Sub
        .Unprotect "171717"
        .Rows(dic(CStr(Me.TextBox_ID.Value))).Delete
        UserForm_Initialize
        .Protect "171717"
        Call temizle
        TextBox_Tarih = Format(Date, "dd.mm.yyyy")
    End With
   
    TextBox_Tarih.SetFocus
       
    With TextBox_Tarih
                .SelStart = 0
                .SelLength = .TextLength
            End With
           
    btn_KayitEkle.Enabled = True
    Set dic = Nothing
    MsgBox "Kayit silindi..", vbInformation, "Bilgi"
End Sub
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: Excel Vba İle Userform Üzerinden Kayıt Silme Hakkında. - Yazar: feraz - 26/04/2021, 06:27