• DİKKAT

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

Döngüdeki hatayı bulamıyorum...

Katılım
2 Nisan 2006
Mesajlar
32
Excel Vers. ve Dili
2007 türkçe
Aşağıdaki makroyu forumdan almıştım. combobax a yazdığım değeri tablodan aratıyorum ancak yazdığım değer olmasada o an hangi hücre aktifse onu kabul edip textboxları ona göre dolduruyor. Ben msgboxla ARADIĞINIZ DEĞER BULUNAMAMIŞTIR DEYİP makronun sonlanmasını istiyorum. Yardımcı olursanız çok sevinirim.


Private Sub CommandButton6_Click()

For Each hucre1 In Range("a2:A" & WorksheetFunction.CountA(Range("a1:a65000")))
If StrConv(hucre1.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then
hucre1.Select
End If
Next


TextBox1.Value = ActiveCell.Offset(0, 8).Value
TextBox2.Value = ActiveCell.Offset(0, 2).Value
TextBox3.Value = ActiveCell.Offset(0, 3).Value
TextBox4.Value = ActiveCell.Offset(0, 4).Value
TextBox5.Value = ActiveCell.Offset(0, 5).Value
TextBox6.Value = ActiveCell.Offset(0, 6).Value
TextBox7.Value = ActiveCell.Offset(0, 7).Value
TextBox8.Value = ActiveCell.Offset(0, 1).Value
TextBox9.Value = ActiveCell.Offset(0, 9).Value
TextBox10.Value = ActiveCell.Offset(0, 10).Value
TextBox11.Value = ActiveCell.Offset(0, 11).Value
TextBox12.Value = ActiveCell.Offset(0, 12).Value
TextBox13.Value = ActiveCell.Offset(0, 13).Value
TextBox14.Value = ActiveCell.Offset(0, 14).Value
TextBox15.Value = ActiveCell.Offset(0, 15).Value
TextBox16.Value = ActiveCell.Offset(0, 16).Value
TextBox17.Value = ActiveCell.Offset(0, 17).Value




End Sub
 
Aşağıdaki şekilde deneyiniz.

Kod:
Private Sub CommandButton6_Click()
Dim sonuc  As Boolean
sonuc=False
For Each hucre1 In Range("a2:A" & WorksheetFunction.CountA(Range("a1:a65000")))
If StrConv(hucre1.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then
sonuc=True
hucre1.Select
End If
Next

If sonuc=True Then
TextBox1.Value = ActiveCell.Offset(0, 8).Value
TextBox2.Value = ActiveCell.Offset(0, 2).Value
TextBox3.Value = ActiveCell.Offset(0, 3).Value
TextBox4.Value = ActiveCell.Offset(0, 4).Value
TextBox5.Value = ActiveCell.Offset(0, 5).Value
TextBox6.Value = ActiveCell.Offset(0, 6).Value
TextBox7.Value = ActiveCell.Offset(0, 7).Value
TextBox8.Value = ActiveCell.Offset(0, 1).Value
TextBox9.Value = ActiveCell.Offset(0, 9).Value
TextBox10.Value = ActiveCell.Offset(0, 10).Value
TextBox11.Value = ActiveCell.Offset(0, 11).Value
TextBox12.Value = ActiveCell.Offset(0, 12).Value
TextBox13.Value = ActiveCell.Offset(0, 13).Value
TextBox14.Value = ActiveCell.Offset(0, 14).Value
TextBox15.Value = ActiveCell.Offset(0, 15).Value
TextBox16.Value = ActiveCell.Offset(0, 16).Value
TextBox17.Value = ActiveCell.Offset(0, 17).Value
Else
Msgbox "ARADIĞINIZ DEĞER BULUNAMAMIŞTIR"
End If
End Sub
 
Çok TeŞekkÜr Ederİm

Tam İstedİĞİm Gİbİ Oldu Çok TeŞekkÜler. Bİrde Şunu Sorabİlİrmİyİm Textboxlara Sadece BÜyÜk Harf Yazilmasini Nasil SaĞlarim. Hayirli AkŞamlar..
 
Merhaba.
Aşağıdaki kodları denermisiniz?:cool:
Kod:
For Each hucre1 In Range("a2:A" & WorksheetFunction.CountA(Range("a1:a65000")))
If StrConv(hucre1.Value, vbUpperCase) = StrConv(ComboBox1.Value, vbUpperCase) Then
hucre1.Select
TextBox1.Value = ActiveCell.Offset(0, 8).Value
TextBox2.Value = ActiveCell.Offset(0, 2).Value
TextBox3.Value = ActiveCell.Offset(0, 3).Value
TextBox4.Value = ActiveCell.Offset(0, 4).Value
TextBox5.Value = ActiveCell.Offset(0, 5).Value
TextBox6.Value = ActiveCell.Offset(0, 6).Value
TextBox7.Value = ActiveCell.Offset(0, 7).Value
TextBox8.Value = ActiveCell.Offset(0, 1).Value
TextBox9.Value = ActiveCell.Offset(0, 9).Value
TextBox10.Value = ActiveCell.Offset(0, 10).Value
TextBox11.Value = ActiveCell.Offset(0, 11).Value
TextBox12.Value = ActiveCell.Offset(0, 12).Value
TextBox13.Value = ActiveCell.Offset(0, 13).Value
TextBox14.Value = ActiveCell.Offset(0, 14).Value
TextBox15.Value = ActiveCell.Offset(0, 15).Value
TextBox16.Value = ActiveCell.Offset(0, 16).Value
TextBox17.Value = ActiveCell.Offset(0, 17).Value
Exit For
End If
Next
End Sub
 
ilginiz için çok teşekkürler.

yazdığınız kodun açıklamasını yapabilirmisiniz başka yerlerde nasıl kullanabilmek adına. Herşey için çok teşekkürler. Paylaşmak güzel şey...
 
Geri
Üst