Makroda hata bulamadım bir türlü.

istanbulcahan

Altın Üye
Katılım
11 Ocak 2008
Mesajlar
1,382
Excel Vers. ve Dili
Office 365 (Türkçe)
Altın Üyelik Bitiş Tarihi
05-11-2024
Hayırlı günler. Bir forumdan aldığım makronun verilerini değiştirdim, bazı kodlarını da haliyle sildim. Bur da hata veriyor, ama hatayı çözemedim.
Kod:
im BlnVal As Boolean

Private Sub UserForm_Initialize()
    Dim IdVal As Integer
    IdVal = fn_LastRow(Sheets("Data"))
    frmData.txtId = IdVal
End Sub
Sub cmdAdd_Click()
    On Error GoTo ErrOccured
    BlnVal = 0
    Call Data_Validation
    If BlnVal = 0 Then Exit Sub
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
   
    With Sheets("Data")
        .Cells(iCnt, 1) = iCnt - 1
        .Cells(iCnt, 2) = frmData.txtName
        .Cells(iCnt, 3) = frmData.txtCNum
        .Cells(iCnt, 4) = frmData.txtCNum
        .Cells(iCnt, 5) = frmData.txtCNum
        .Cells(iCnt, 6) = frmData.txtCNum
        .Cells(iCnt, 7) = frmData.txtEAddr
        .Cells(iCnt, 8) = frmData.txtCNum
        .Cells(iCnt, 9) = frmData.txtRemarks
     
        If .Range("A1") = "" Then
            .Cells(1, 1) = "Id"
            .Cells(1, 2) = "Ad-Soyad"
            .Cells(1, 3) = "Sicil No"
            .Cells(1, 4) = "İzin Başlama Tarihi"
            .Cells(1, 5) = "İzin Bitiş Tarihi"
            .Cells(1, 6) = "Kullanılan İzin"
            .Cells(1, 7) = "E-mail Adresi"
            .Cells(1, 8) = "İletişim No"
            .Cells(1, 9) = "Açıklama"
           
            .Columns("A:G").Columns.AutoFit
            .Range("A1:G1").Font.Bold = True
            .Range("A1:G1").LineStyle = xlDash
           
        End If
    End With
   
    Dim IdVal As Integer
    IdVal = fn_LastRow(Sheets("Data"))
    frmData.txtId = IdVal
   
ErrOccured:
    Application.ScreenUpdating = True
    Application.EnableEvents = True
   
End Sub

Function fn_LastRow(ByVal Sht As Worksheet)

    Dim lastRow As Long
    lastRow = Sht.Range("A65536").End(3).Row + 1
    lRow = Sht.Range("A65536").End(3).Row + 1
    Do While Application.CountA(Sht.Rows(lRow)) = 0 And lRow <> 1
        lRow = lRow - 1
    Loop
    fn_LastRow = lRow

End Function

Private Sub cmdCancel_Click()
    Unload Me
End Sub


Sub Data_Validation()
     If txtName = "" Then
        MsgBox "Ad-Soyad Girin!", vbInformation, "Ad-Soyad"
        Exit Sub
     ElseIf txtCNum = "" Then
        MsgBox "Sicil No Girin!", vbInformation, "Sicilno"
        Exit Sub
     ElseIf txtCNum = "" Then
        MsgBox "İzin Başlama Tarihi Girin!", vbInformation, "İzinbaşlamatarihi"
        Exit Sub
     ElseIf txtCNum = "" Then
        MsgBox "İzin Bitiş Tarihi Girin!", vbInformation, "İzinbitiştarihi"
        Exit Sub
     ElseIf txtCNum = "" Then
        MsgBox "Kullanılan İzin Girin!", vbInformation, "Kullanilanizin"
        Exit Sub
     ElseIf txtEAddr = "" Then
        MsgBox "Mail Adresi!", vbInformation, "E-mail Adresi"
        Exit Sub
     ElseIf txtCNum = "" Then
        MsgBox "İletişim No Girin", vbInformation, "İletişim No"
        Exit Sub
     Else
        BlnVal = 1
     End If



Private Sub cmdClear_Click()
    Application.ScreenUpdating = False
        txtId.Text = ""
        txtName.Text = ""
        obMale.Value = True
        txtLocation = ""
        txtEAddr = ""
        txtCNum = ""
        txtRemarks = ""
    Application.ScreenUpdating = True
End Sub
Konuda yer alan excelde yüzdelik formül nasıl olmalı yanlışlıkla yazmışım. https://www.excel.web.tr/threads/makroda-hata-bulamadim-bir-tuerlue.194883/watch
 
Üst