• DİKKAT

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

textbox a girilen verinin aratılması ve girilmiş ise hata mesajı çıkarması

Katılım
31 Ağustos 2008
Mesajlar
52
Excel Vers. ve Dili
2007-türkçe
ekte sorum ile ilgili dosyayı gönderiyorum
userformda textbox a veri girip excel e yazdırıyorum fakat girilicek veri daha önceden girilmiş ise programın bunu aratmasını ve verinin zaten girildiğini belirten bir msgbox göstermesini istiyorum.


2. bir soru olarak yine aynı dosyada sayfa2 de b sütununda yazan verilerden sonra (ardı sıra) gelecek veriyi textbox ta görmemi sağlayacak bir kod tavsiyesinde bulunabilirmisiniz?

örnek olarak gönderdiğim dosyada b9 hücresinde IA2007 yazıyor userformda textboxta IA2008 i görebilirmiyim?
 

Ekli dosyalar

Yanıt

Kod:
Private Sub CommandButton2_Click()
Dim s2 As Worksheet
Dim son, sat, s As Integer
Set s2 = Sheets("Sayfa2")
If TextBox1 = "" Then: MsgBox "Önce veri girmelisiniz.", vbInformation: Exit Sub
son = s2.Cells(65536, "b").End(xlUp).Row + 1
For sat = 2 To son
If s2.Cells(sat, "b") = TextBox1 Then
MsgBox "Bu veri daha önce girilmiş", vbInformation: Exit Sub: End If: Next
s2.Cells(son, "b") = TextBox1
TextBox1 = Empty
deg = WorksheetFunction.CountA(s2.Range("b2:b65536"))
s = 1
Do While s2.[b2] <> ""
s2.Cells(s + 1, "a") = s
s = s + 1
If s > deg Then Exit Do
Loop
End Sub
Kod:
Private Sub TextBox1_Change()
Dim s2 As Worksheet
Dim sa, s As Integer
Set s2 = Sheets("Sayfa2")
With ListBox1
.Clear
.ColumnCount = 2
.ColumnWidths = "15,75"
End With
For sat = 2 To s2.Cells(65536, "b").End(xlUp).Row
If s2.Cells(sat, "b") Like "*" & TextBox1 & "*" Then
ListBox1.AddItem
ListBox1.List(s, 0) = s2.Cells(sat, "a")
ListBox1.List(s, 1) = s2.Cells(sat, "b")
s = s + 1
End If: Next
End Sub
Kod:
Private Sub UserForm_Initialize()
TextBox1 = "."
TextBox1 = ""
End Sub
 

Ekli dosyalar

ilgilendiğiniz için çok teşekkür ederim fakat programı çalıştırdığımda
"statement invalid outside type block" yazan bir hata ile karşılaşıyorum.
nedeni nedir?
 
Merhaba

Private Sub CommandButton2_Click()
Dim s2 As Worksheet


Kodu yukardaki gibi değiştirerek deneyiniz..
 
Geri
Üst