Ara Bulunamamışsa boş bırak?

Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
Kod:
Private Sub ComboBox6_Change()
Set s2 = ThisWorkbook.Worksheets("Bilgi_Girisi")
s2_sstr = s2.Cells(65536, 2).End(xlUp).Row
[color="red"] ara = s2.Range("b2:b" & s2_sstr).Find(ComboBox6.Text).Row[/color]
ComboBox3 = Cells(ara, 3)
ComboBox4 = Cells(ara, 4)
TextBox3 = Cells(ara, 5)
TextBox4 = Cells(ara, 6)
TextBox5 = Cells(ara, 7)
TextBox6 = Cells(ara, 8)
TextBox7 = Cells(ara, 9)
TextBox8 = Cells(ara, 10)
TextBox9 = Cells(ara, 11)
TextBox10 = Cells(ara, 12)
End Sub
eğer değer varsa altındakiler çalışsın yoksa boş olsun ?
yeti kayıt ekleneceği zaman hata veriyor
 
Son düzenleme:
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
ComboBox6 ya girilen değer b2:b(snst) aralığında bulunamamışsa kayıt bulunamadı dedirtemezmiyiz?
 

Kemal Demir

Özel Üye
Katılım
29 Temmuz 2004
Mesajlar
2,108
Merhaba;

Her halukarda arama soncunda userform nesnelerinden en az birini dolu olması şartı ile aşağıdaki kod size yardımcı olabilir.

Örnek Textbox3 kesinlikle dolu olacak ise.

Kodların sonuna;
Kod:
if  textbox3.value="" then
MsgBox("Aradıgınız Veri bulunamadı")
Exit Sub
End if
Umarım yardımcı olabilmişimdir.
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
Merhaba;

Her halukarda arama soncunda userform nesnelerinden en az birini dolu olması şartı ile aşağıdaki kod size yardımcı olabilir.

Örnek Textbox3 kesinlikle dolu olacak ise.

Kodların sonuna;
Kod:
if  textbox3.value="" then
MsgBox("Aradıgınız Veri bulunamadı")
Exit Sub
End if
Umarım yardımcı olabilmişimdir.
Hocam Olay şu

Kod:
Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
...................
s2.Select
ComboBox6.ColumnCount = 3
ComboBox6.ColumnWidths = "75;40;50"
ComboBox6.ListRows = "5"
ComboBox6.RowSource = "Bilgi_Girisi!b3: D" & Cells(65536, 2).End(xlUp).Row

.....................
Application.ScreenUpdating = True
End Sub
comboboxa verileri yükledik
B==>>Tc kimlik no
c==>>Adı
d==>>Soyadı
Kod:
Private Sub ComboBox6_Change()
Set s2 = ThisWorkbook.Worksheets("Bilgi_Girisi")
s2_sstr = s2.Cells(65536, 2).End(xlUp).Row
 ara = s2.Range("b2:b" & s2_sstr).Find(ComboBox6.Text).Row
ComboBox3 = Cells(ara, 3)
ComboBox4 = Cells(ara, 4)
TextBox3 = Cells(ara, 5)
TextBox4 = Cells(ara, 6)
TextBox5 = Cells(ara, 7)
TextBox6 = Cells(ara, 8)
TextBox7 = Cells(ara, 9)
TextBox8 = Cells(ara, 10)
TextBox9 = Cells(ara, 11)
TextBox10 = Cells(ara, 12)
End Sub
Tc/Ad/Soyadı görüp mevcut tc yi görerek userformdaki diğer nesneleri dolduruyoruz....
Ancak yanı userformla yeni kayıtta yapılacak onun için boş ve tc no yoksada hata vermemesi lazım Len(Combobox6.text) <> 11 Thern Exi,t sub ekledi,m buda tamam ama kalanı problem
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
Kod:
Private Sub ComboBox6_Change()

Set s2 = ThisWorkbook.Worksheets("Bilgi_Girisi")
s2_sstr = s2.Cells(65536, 2).End(xlUp).Row

If Len(ComboBox6.Text) <> 11 Then Exit Sub

For Each knt In s2.Range("b3:b" & s2.Cells(65536, 2).End(xlUp).Row)
 'MsgBox knt.Value
 If knt.Value = ComboBox6.Text Then
    MsgBox knt.Value & "/////" & ComboBox6.Text
    ara = s2.Range("b3:b" & s2_sstr).Find(ComboBox6.Text).Row
    ComboBox3 = Cells(ara, 3)
    ComboBox4 = Cells(ara, 4)
    TextBox3 = Cells(ara, 5)
    TextBox4 = Cells(ara, 6)
    TextBox5 = Cells(ara, 7)
    TextBox6 = Cells(ara, 8)
    TextBox7 = Cells(ara, 9)
    TextBox8 = Cells(ara, 10)
    TextBox9 = Cells(ara, 11)
    TextBox10 = Cells(ara, 12)
'ElseIf knt.Value <> ComboBox6.Text Then
''son:
'            ComboBox3 = ""
'            ComboBox4 = ""
'            TextBox3 = ""
'            TextBox4 = ""
'            TextBox5 = ""
'            TextBox6 = ""
'            TextBox7 = ""
'            TextBox8 = ""
'            TextBox9 = ""
'            TextBox10 = ""
End If
Next
End Sub
&#351;eklinde denedim arama sonucunda veri yoksa hata vermiyor ancak ' yerleri kald&#305;r&#305;ncada i&#351;lemiyor bir fikri olan varm&#305;?
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
Kod:
Private Sub ComboBox6_Change()

Set s2 = ThisWorkbook.Worksheets("Bilgi_Girisi")
s2_sstr = s2.Cells(65536, 2).End(xlUp).Row

If Len(ComboBox6.Text) <> 11 Then GoTo bos

For Each knt In s2.Range("b3:b" & s2.Cells(65536, 2).End(xlUp).Row)
 If knt.Value = ComboBox6.Text Then
    ara = s2.Range("b3:b" & s2_sstr).Find(ComboBox6.Text).Row
    ComboBox3 = Cells(ara, 3)
    ComboBox4 = Cells(ara, 4)
    TextBox3 = Cells(ara, 5)
    TextBox4 = Cells(ara, 6)
    TextBox5 = Cells(ara, 7)
    TextBox6 = Cells(ara, 8)
    TextBox7 = Cells(ara, 9)
    TextBox8 = Cells(ara, 10)
    TextBox9 = Cells(ara, 11)
    TextBox10 = Cells(ara, 12)
    GoTo son
End If
Next

bos:
    ComboBox3 = ""
    ComboBox4 = ""
    TextBox3 = ""
    TextBox4 = ""
    TextBox5 = ""
    TextBox6 = ""
    TextBox7 = ""
    TextBox8 = ""
    TextBox9 = ""
    TextBox10 = ""

son:

End Sub
bir re&#351;it kendin s&#246;yle kendin i&#351;it durumu daha ya&#351;and&#305; ve bitti. :)
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
est. hocam &#246;rnekleri inceleyerek birazda de&#351;eleyerek bir &#351;eyler yapmaya &#231;al&#305;&#351;&#305;yorum.
 
Üst