• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Combobox ile seçilen sayfaya kayıt

Katılım
21 Şubat 2017
Mesajlar
64
Excel Vers. ve Dili
2022 365 TÜRKÇE
merhabalar
ekteki dosyada user form üzerindeki combobox ta seçilen sayfaya kayıt etmesini istiyorum ,
konu ile ilgil dosyam ektedir.yardımlarınız için şimdiden teşekkürler.
 

Ekli dosyalar

Merhaba kodları Userform a ekleyip kayıt yapabilirsiniz.
Kod:
Private Sub UserForm_Initialize()
    With ComboBox1
        .AddItem "Yapılan İş"
        .AddItem "Masraf"
    End With
End Sub
Kod:
Private Sub CommandButton1_Click()
Dim s1 As Worksheet, son As Long, say As Byte, sor As Byte
Set s1 = Sheets(ComboBox1.Text)
With s1
    son = .Cells(Rows.Count, 1).End(3).Row + 1
    say = WorksheetFunction.CountIf(.Range("B2:B" & son), TextBox2.Value)
    If say > 1 Then
    sor = MsgBox(TextBox2.Value & " Kaydı var! Kayıt yapılsın mı?", vbQuestion + vbYesNo, "Mükerrer Kayıt")
        If sor = vbNo Then
            Exit Sub
        Else
            .Cells(son, 1) = CDate(TextBox1.Value)
            .Cells(son, 2) = TextBox2.Value
            .Cells(son, 3) = TextBox3.Value
            .Cells(son, 3).NumberFormat = "#,##0.00"
        End If
    Else
        .Cells(son, 1) = CDate(TextBox1.Value)
        .Cells(son, 2) = TextBox2.Value
        .Cells(son, 3) = TextBox3.Value
        .Cells(son, 3).NumberFormat = "#,##0.00"
    End If
End With
End Sub
 
Merhaba kodları userform a ekleyiniz.

Onay buton kodları güncellendi.
Kod:
Private Sub CommandButton1_Click()
Dim s1 As Worksheet, son As Long, say As Byte, sor As Byte

If ComboBox1.Value = Empty Then
    MsgBox "Sayfa seçimi yapmadınız!", vbExclamation, ""
    Exit Sub
End If

Set s1 = Sheets(ComboBox1.Text)
With s1
    son = .Cells(Rows.Count, 1).End(3).Row + 1
    say = WorksheetFunction.CountIf(.Range("B2:B" & son), TextBox2.Value)
    If say >= 1 Then
    sor = MsgBox(TextBox2.Value & " Kaydı var! Kayıt yapılsın mı?", vbQuestion + vbYesNo, "Mükerrer Kayıt")
        If sor = vbNo Then
            temizle
            Exit Sub
        Else
            .Cells(son, 1) = CDate(TextBox1.Value)
            .Cells(son, 2) = TextBox2.Value
            .Cells(son, 3) = TextBox3.Value
            .Cells(son, 3).NumberFormat = "#,##0.00"
        End If
    Else
        .Cells(son, 1) = CDate(TextBox1.Value)
        .Cells(son, 2) = TextBox2.Value
        .Cells(son, 3) = TextBox3.Value
        .Cells(son, 3).NumberFormat = "#,##0.00"
    End If
End With
temizle
End Sub

Çift tıklayınca tarihin yazılması.
Kod:
Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox1.Text = CDate(Date)
End Sub

Temizle kodları
Kod:
Sub temizle()
Dim nesne As Object
    For Each nesne In Me.Controls
        If TypeOf nesne Is MSForms.TextBox Or TypeOf nesne Is MSForms.ComboBox Then
            nesne.Value = Empty
        End If
    Next
End Sub
 
Amin cümlemizden, teşekkür ederim.
 
Geri
Üst