• DİKKAT

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

Soru Change Kodu ile Çoklu Arama

TURKOLOG

Altın Üye
Katılım
13 Kasım 2008
Mesajlar
745
Excel Vers. ve Dili
2016 64 TR
Herkese Merhaba aşağıdaki kodla B sütununa göre arama yapmaktayım . Ben aşağıdaki kod yapısı ile devam ederek (optionbutton kullanmadan ) B . C. D sütünlarına göre arama yapmak istiyorum bu mümkün müdür. B de sicil C de isim D de soy isim var

Kod:
Private Sub TextBox22_Change()
Dim bul
    On Error Resume Next
    bul = Sheets("VERİ").Range("B2:B100000").Find(What:=TextBox22, LookIn:=xlValues, LookAt:=xlWhole).Row
    TextBox21.Value = Sheets("VERİ").Cells(bul, 1).Value
    TextBox23.Value = Sheets("VERİ").Cells(bul, 3).Value
    TextBox24.Value = Sheets("VERİ").Cells(bul, 4).Value
    ComboBox15.Value = Sheets("VERİ").Cells(bul, 5).Value
    ComboBox16.Value = Sheets("VERİ").Cells(bul, 6).Value
    TextBox25.Text = Sheets("VERİ").Cells(bul, 7).Value
    ComboBox17.Text = Sheets("VERİ").Cells(bul, 8).Value
    TextBox26.Text = Sheets("VERİ").Cells(bul, 9).Value
    TextBox27.Text = Sheets("VERİ").Cells(bul, 10).Value
    ComboBox18.Text = Sheets("VERİ").Cells(bul, 11).Value
    ComboBox19.Text = Sheets("VERİ").Cells(bul, 12).Value
    ComboBox20.Text = Sheets("VERİ").Cells(bul, 13).Value
    ComboBox21.Text = Sheets("VERİ").Cells(bul, 14).Value
    TextBox28.Text = Sheets("VERİ").Cells(bul, 15).Value
    TextBox31.Text = Sheets("VERİ").Cells(bul, 16).Value
    ComboBox22.Text = Sheets("VERİ").Cells(bul, 17).Value
    TextBox29.Text = Sheets("VERİ").Cells(bul, 18).Value
    TextBox30.Text = Sheets("VERİ").Cells(bul, 19).Value
    TextBox33.Text = Sheets("VERİ").Cells(bul, 20).Value
    TextBox34.Text = Sheets("VERİ").Cells(bul, 21).Value
    TextBox35.Text = Sheets("VERİ").Cells(bul, 34).Value
    TextBox36.Text = Sheets("VERİ").Cells(bul, 35).Value
End Sub
 
Merhaba.

Aşağıdaki kod ile istediğinizi gerçekleştirebilirsiniz.

Kod:
Sub test()
    Dim Bul As Range
    'Sicil No ara
    Bul = Sheets("VERİ").Range("B2:B" & Rows.Count).Find(What:=TextBox22, LookIn:=xlValues, LookAt:=xlWhole).Row
    If Bul Is Nothing Then 'Eğer sicil No bulamadıysa
        'İsim Ara
        Bul = Sheets("VERİ").Range("C2:C" & Rows.Count).Find(What:=TextBox22, LookIn:=xlValues, LookAt:=xlWhole).Row
        If Bul Is Nothing Then 'Eğer isim bulamadıysa
            'Soyisim ara
            Bul = Sheets("VERİ").Range("D2:D" & Rows.Count).Find(What:=TextBox22, LookIn:=xlValues, LookAt:=xlWhole).Row
        End If
    End If
    If Bul Is Nothing Then
        MsgBox "Aradığınız veri 'Sicil No', 'İsim' ve 'Soyisim' alanlarının hiçbirinde bulunmadı."
        Exit Sub
    End If
  
    MsgBox "Bulunan: " & Bul.Text
End Sub

Aşağıdaki gibi olan satırları da
Kod:
TextBox21.Value = Sheets("VERİ").Cells(bul, 1).Value
Aşağıdaki gibi yapmalısınız.
Kod:
TextBox21.Value = Sheets("VERİ").Cells(bul.row, 1).Value
 
Merhaba.

Aşağıdaki kod ile istediğinizi gerçekleştirebilirsiniz.

Kod:
Sub test()
    Dim Bul As Range
    'Sicil No ara
    Bul = Sheets("VERİ").Range("B2:B" & Rows.Count).Find(What:=TextBox22, LookIn:=xlValues, LookAt:=xlWhole).Row
    If Bul Is Nothing Then 'Eğer sicil No bulamadıysa
        'İsim Ara
        Bul = Sheets("VERİ").Range("C2:C" & Rows.Count).Find(What:=TextBox22, LookIn:=xlValues, LookAt:=xlWhole).Row
        If Bul Is Nothing Then 'Eğer isim bulamadıysa
            'Soyisim ara
            Bul = Sheets("VERİ").Range("D2:D" & Rows.Count).Find(What:=TextBox22, LookIn:=xlValues, LookAt:=xlWhole).Row
        End If
    End If
    If Bul Is Nothing Then
        MsgBox "Aradığınız veri 'Sicil No', 'İsim' ve 'Soyisim' alanlarının hiçbirinde bulunmadı."
        Exit Sub
    End If
 
    MsgBox "Bulunan: " & Bul.Text
End Sub

Aşağıdaki gibi olan satırları da
Kod:
TextBox21.Value = Sheets("VERİ").Cells(bul, 1).Value
Aşağıdaki gibi yapmalısınız.
Kod:
TextBox21.Value = Sheets("VERİ").Cells(bul.row, 1).Value
Sayın @dalgalikur çok teşekkür ederim elinize emeğinize sağlık kod çalıştı.
 
Geri
Üst