• DİKKAT

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

vba ile sonraki kayıt bulma hk.

Katılım
17 Kasım 2009
Mesajlar
295
Excel Vers. ve Dili
2010
merhaba arkadaşlar aşağıdaki kod ile textbox içinde kayıt buluyor fakat aynı kayıttan kaç tane varsa enter tuşuna basınca sonrakini bulmasını istiyorum.

Private Sub TextBox22_Change()
Dim t As String
Dim i As Integer
t = TextBox22.Text
ListBox1.ListIndex = -1
If TextBox22.Text = "" Then Exit Sub
For i = 0 To ListBox1.ListCount - 1
If UCase(ListBox1.List(i)) Like UCase(t & "*") Then
ListBox1.ListIndex = i
Exit Sub
End If
Next i

End Sub
 
.

Kod:
Private Sub TextBox22_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

If KeyCode = 13 Then

Dim t As String
Dim i As Integer
t = TextBox22.Text
ListBox1.ListIndex = -1
If TextBox22.Text = "" Then Exit Sub
For i = 0 To ListBox1.ListCount - 1
If UCase(ListBox1.List(i)) Like UCase(t & "*") Then
ListBox1.ListIndex = i
Exit Sub
End If
Next i

End If

End Sub

.
 
merhaba bu şekilde yapıncada enter tuşuna basınca commandbuttonlara basıyor bunun yerine yine bir button ekleyip yapabiirmiyiz aşağıdakilerini koddan çıkardım ama bir tane buluyor sonrakini bulmuyor
If KeyCode = 13 Then
end if
 
bu kodları aynen eklediğimde 1 kayıt buluyor sonraki kayıtları bulmuyor yada commandbutton içine de ekleyincede sadece 1 tane kaydı buluyor
 
Bu kodları siz mi yazdınız.
Kodlarınızda ilk eşleştirmeyi yapınca kodu bitir komutu var. O yüzden 1 sonuç geliyor.

.
 
daha önceden bu sitede veya başka bir siteden buldum fakat aynı kayıtlar çoğalmaya başlayınca sonrakini bul komutuna ihtiyaç duydum
 
.

Ben, sorunuzdaki sonraki eşleşenleri de bulması kısmını kaçırmışım. Yapılabilir.
Ufak bir örnek dosya ekleyebilir misiniz. Test etmek için.

.
 
merhaba örnek dosya ekledim arama userforma arama butonu koydum sonrakini bul yapmaya çalıştığımda bulmuyor
 

Ekli dosyalar

Merhaba arkadaşlar bu konu hakkında yardım edebilecek kimse varmı
 
.

Yeni bir buton ekleyin. İlk aramanızdan sonra 2. ve sonraki seçenekleri getirmek için bu butonu kullanın.

Kod:
Private Sub CommandButton2_Click()

a = Me.ListBox1.ListIndex + 1
Dim t As String
Dim i As Integer
t = arama.Text
ListBox1.ListIndex = -1
If arama.Text = "" Then Exit Sub
For i = a To ListBox1.ListCount - 1
If UCase(ListBox1.List(i)) Like UCase(t & "*") Then
ListBox1.ListIndex = i
Exit Sub
End If
Next i

End Sub

.
 
a = Me.ListBox1.ListIndex + 1 Dim t As String Dim i As Integer t = arama.Text ListBox1.ListIndex = -1 If arama.Text = "" Then Exit Sub For i = a To ListBox1.ListCount - 1 If UCase(ListBox1.List(i)) Like UCase(t & "*") Then ListBox1.ListIndex = i Exit Sub End If Next i
teşekkür ederim
 
Geri
Üst