• DİKKAT

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

Hücrelere TextBox ile tarih aktarma

Katılım
4 Mart 2011
Mesajlar
38
Excel Vers. ve Dili
Türkçe/2010
Hücrelere CDate ile tarih aktarmak zorundayım. TextBox ile aktardığım bu verilerde, boş geçtiğim TextBoxlarda hata veriyor. Bir türlü düzeltemedim. Yardımlarınızı bekler, saygılarımı sunarım.




Private Sub CommandButton1_Click()

Dim Satır As Long, Say As Byte


Satır = Range("C2300").End(3).Row + 1
Cells(Satır, "B") = Satır - 10
Cells(Satır, "C") = TextBox1.Text

Range("D6") = CDate(TextBox2)

Cells(Satır, "D") = CDate(TextBox3)
Cells(Satır, "E") = CDate(TextBox4)
Cells(Satır, "F") = CDate(TextBox5)
Cells(Satır, "G") = CDate(TextBox6)
Cells(Satır, "H") = CDate(TextBox7)
Cells(Satır, "I") = CDate(TextBox8)
Cells(Satır, "J") = CDate(TextBox9)
Cells(Satır, "K") = CDate(TextBox10)
Cells(Satır, "L") = CDate(TextBox11)
Cells(Satır, "M") = CDate(TextBox12)
Cells(Satır, "N") = CDate(TextBox13)
Cells(Satır, "O") = CDate(TextBox14)
Cells(Satır, "P") = CDate(TextBox15)
Cells(Satır, "Q") = CDate(TextBox16)
Cells(Satır, "R") = CDate(TextBox17)
Cells(Satır, "S") = CDate(TextBox18)
Cells(Satır, "T") = CDate(TextBox19)
Cells(Satır, "U") = CDate(TextBox20)
Cells(Satır, "V") = CDate(TextBox21)
Cells(Satır, "W") = CDate(TextBox22)

With KAYIT_FORMU.ListBox1
.BackColor = vbBlue
.ColumnCount = 22
.ColumnWidths = "140;80;80;80;80;80;80;80;80;80;80;80;80;80;80;80;80;80;80;80;80;80"
.ForeColor = vbWhite
If Sheets("İZİN").Range("C11") = Empty Then
.RowSource = Empty
Else
.RowSource = "İZİN!C11:W" & [İZİN!B2300].End(1).Row
End If
End With

MsgBox "Kayıt işlemi tamamlanmıştır.", vbInformation, "Kayıt İşlemi"

End Sub
 
Merhaba
Kodların "Textbox" verilerini sayfaya ekleyen bölümünü; aşağıdaki gibi deneyiniz
Kod:
[SIZE="2"]Private Sub CommandButton1_Click()
[COLOR="Red"]Dim n As Integer[/COLOR]
Dim Satır As Long, Say As Byte

Satır = Range("C2300").End(3).Row + 1
Cells(Satır, "B") = Satır - 10
Cells(Satır, "C") = TextBox1.Text

[COLOR="Blue"]If IsDate(TextBox2) = True Then Range("D6") = CDate(TextBox2)
For n = 3 To 22
If IsDate(Controls("Textbox" & n)) = True Then
Cells(Satır, n + 1) = CDate(Controls("Textbox" & n))
End If
Next[/COLOR]

With KAYIT_FORMU.ListBox1
.BackColor = vbBlue
.ColumnCount = 22
.ColumnWidths = "140;80;80;80;80;80;80;80;80;80;80;80;80;80;80;80; 80;80;80;80;80;80"
.ForeColor = vbWhite
If Sheets("İZİN").Range("C11") = Empty Then
.RowSource = Empty
Else
.RowSource = "İZİN!C11:W" & [İZİN!B2300].End(1).Row
End If
End With

MsgBox "Kayıt işlemi tamamlanmıştır.", vbInformation, "Kayıt İşlemi"
End Sub[/SIZE]
 
Son düzenleme:
Sayın PLİNT öncelikle çok teşekkür ederim. İlave etmiş olduğunuz kodları denediğim de For n=3 To 22 döngüsüne geldiğinde variable hatası veriyor.
 
Kod sayfanızın başında "Option Explicit" varsa "n" i tanımlamadığımız için "Veriable not defined" hatası vermiştir.
yukarıdaki kodlarda değişen gibi tanımı ekleyelim

Kod:
Dim n As Integer
 
PLİNT kardeş size zahmet veriyorum ya. Bu sefer de aşağıdaki satırda ikaz veriyor. Adım adım bitireceğiz herhalde.

If IsDate(Controls("Textbox" & n)) = True Then
 
TAMAMDIR ! PLİNT kardeşim size çok teşekkür ediyorum. Sağolun Varolun...
Rica ederim
Bende hangi "Textbox" hatalı bulmak için aşağıdaki kodu hazırlamıştım
siz halletmişsiniz
Kod:
[SIZE="2"]Private Sub CommandButton1_Click()
Dim n As Integer
On Error Resume Next
For n = 3 To 22
If IsDate(Controls("Textbox" & n)) = True Then
If Err <> 0 Then MsgBox n & ".Textbox"
End If
Next
End Sub[/SIZE]
 
Geri
Üst