• DİKKAT

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

Enter ile Hücreden Butona Geçilmesi

Katılım
23 Eylül 2017
Mesajlar
43
Excel Vers. ve Dili
2016
Merhabalar,
Excel projemde kayıt sayfasından tüm işlemleri yapıyorum ve sizden şöyle bir ricam var
Örneğin : E21 ve E22 hücresine bilgileri girip butona tıkladığımda kayıt sayfasına bilgileri atıyor.
Lakin işlemlerim fazla olduğu için E22 hücresinden sonra enter a basınca butona geçsin birdaha enter yapınca butona bassın.
Ve bunun diğer butonlarda da yapmak istiyorum.
İlgilenen İlgilenmeyen Herekese Teşekkür Eder İyi Günler Dilerim
 
E22'ye veri girdiğinizde kodların çalışmasını istiyorsanız WorksheetChange olayını kullanabilirsiniz. Böylece herhangi bir düğmeye basmanız gerekmez.
Örneğin aşağıdaki kodları veri girdiğiniz sayfanın kod bölümüne yapıştırısanız, E21'e veri girdiğinizde E22'yi seçer, E22'ye veri girdiğinizde ise:
Eğer E21 boşsa uyarı verir
E21 doluysa rapor isimli makroyu çalıştırır:

Kod:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [E21]) Is Nothing Then GoTo 10
If Target = "" Then Exit Sub
[E22].Select
10:
If Intersect(Target, [E22]) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
If [E21] = "" Then
    MsgBox "E21 hücresi boş!", vbCritical
    Target = ""
    [E21].Select
Else
    Call rapor
End If
End Sub
 
ilgili dosyayı ekledim burdan yola çıkalım

İlginiz için teşekkür ederim.
http://s7.dosya.tc/server2/dbt8j8/veri_girisi.xlsx.html

Burdaki makro çalıştırması olayı yerine commandbutona1 geçmesi işlevini nasıl tanımlarız
Örneğin E21 ve E22 Dolu entera bastım, E23 Hücresine değilde Commandbutona geçsin ve birdaha enter yapınca Butondaki işlev gerçekleşsin
 
Makro çalıştırması yerine command butondaki kodları verdiğim kodlara ekleyebilirsiniz:

Kod:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [E21]) Is Nothing Then GoTo 10
If Target = "" Then Exit Sub
[E22].Select
10:
If Intersect(Target, [E22]) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
If [E21] = "" Then
    MsgBox "E21 hücresi boş!", vbCritical
    Target = ""
    [E21].Select
Else
   command butondaki kodlar (ilk ve son satır hariç)
End If
End Sub
 
Ya da illa bir düğmeyle işlem yapmak istiyorsanız:

Kod:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [E20]) Is Nothing Then GoTo 10
If Target = "" Then Exit Sub
[E21].Select
10:
If Intersect(Target, [E21]) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
If [E20] = "" Then
    MsgBox "Cari adı boş!", vbCritical
    Target = ""
    [E20].Select
Else
    uyarı = MsgBox([E20] & " cari hesabı için " & [E19] & " işlemine " & _
    Format([E21], "#,###.00 TL") & " kaydetmek istiyor musunuz?", vbYesNo)
    If uyarı = vbYes Then
        'command butondaki kodlar (ilk ve son satır hariç)
    End If
End If
End Sub

Bu arada kodları örnek dosyanıza göre güncelledim.
 
Böyle yapsanız olurmu.!


Kod:
Private Sub CommandButton1_Click()
MsgBox "deneme1"
End Sub
Private Sub CommandButton2_Click()
MsgBox "deneme2"
End Sub
Private Sub CommandButton3_Click()
MsgBox "deneme3"
End Sub

Private Sub CommandButton4_Click()
MsgBox "deneme4"
End Sub
Private Sub CommandButton5_Click()
MsgBox "deneme5"
End Sub
Private Sub CommandButton6_Click()
MsgBox "deneme6"
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("e:e,h:h")) Is Nothing Then Exit Sub

If Target.Column = 5 Then
If Target.Row = 6 Then
CommandButton1_Click
End If
If Target.Row = 13 Then
CommandButton2_Click
End If

If Target.Row = 21 Then
CommandButton3_Click
End If
Cancel = True
End If


If Target.Column = 8 Then
If Target.Row = 7 Then
CommandButton4_Click
End If
If Target.Row = 14 Then
CommandButton5_Click
End If

If Target.Row = 20 Then
CommandButton6_Click
End If
Cancel = True
End If

End Sub

not: kodların çalışması için dosyanın uzantısı xlms veya xls olmalı tabi makro güvenliğide düşük veya orta olmalı
 
alakanıza teşekkür ederim arkadaşlar.
halit bey yazdığınız kodlar istediğim gibi. şunu ekleme şansımız varmı enter ile butona geçicek enter ile ekliycek
 
alakanıza teşekkür ederim arkadaşlar.
halit bey yazdığınız kodlar istediğim gibi. şunu ekleme şansımız varmı enter ile butona geçicek enter ile ekliycek

Ben bu dediğinizi yapamadım
 
Geri
Üst