• DİKKAT

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

kod hata veriyor

Katılım
21 Şubat 2011
Mesajlar
8
Excel Vers. ve Dili
2007
Private Sub CommandButton1_Click()
If ComboBox1.Text = "OCAK" Then ComboBox2.Text = "1"
Sheets("Sayfa2").Select
Range("B3").Value = TextBox1.Value
Range("C3").Value = TextBox2.Value
Range("D3").Value = TextBox3.Value
Range("F3").Value = TextBox5.Value
Range("G3").Value = TextBox6.Value
Range("H3").Value = TextBox7.Value
Range("I3").Value = TextBox8.Value

Else

If ComboBox1.Text = "OCAK" Then ComboBox2.Text = "2"
Sheets("Sayfa2").Select
Range("B4").Value = TextBox1.Value
Range("C4").Value = TextBox2.Value
Range("D4").Value = TextBox3.Value
Range("F4").Value = TextBox5.Value
Range("G4").Value = TextBox6.Value
Range("H4").Value = TextBox7.Value
Range("I4").Value = TextBox8.Value


End If

End If






End Sub
ukarıdaki kod hata veriyor yada son yazdıgım bütün text bax ları bütün hücrelere birden yazıyor önce yazdıgım veriler siliniyor
 
Syn. Arifdurgut;
Kodtaki kırmızı ile belirtiğim satırlar
combobox1'in texti "Ocak" İse Combobox2' nin texti enson yazdığını 2 olduğundan en sondaki işlemi yapmakta.

Siz tam olarak ne yapmak istediğinizi bir örnek dosya ile açıklarsanız yardımcı olalım.
Kod:
Private Sub CommandButton1_Click()
[COLOR="Red"]If ComboBox1.Text = "OCAK" Then ComboBox2.Text = "1"[/COLOR]
Sheets("Sayfa2").Select
Range("B3").Value = TextBox1.Value
Range("C3").Value = TextBox2.Value
Range("D3").Value = TextBox3.Value
Range("F3").Value = TextBox5.Value
Range("G3").Value = TextBox6.Value
Range("H3").Value = TextBox7.Value
Range("I3").Value = TextBox8.Value

Else

[COLOR="Red"]If ComboBox1.Text = "OCAK" Then ComboBox2.Text = "2"[/COLOR]
Sheets("Sayfa2").Select
Range("B4").Value = TextBox1.Value
Range("C4").Value = TextBox2.Value
Range("D4").Value = TextBox3.Value
Range("F4").Value = TextBox5.Value
Range("G4").Value = TextBox6.Value
Range("H4").Value = TextBox7.Value
Range("I4").Value = TextBox8.Value


End If

End If
 
Kod:
Private Sub ComboBox1_Change()
If ComboBox1.Text = "OCAK1" Then ComboBox2.Text = "1"
If ComboBox1.Text = "OCAK2" Then ComboBox2.Text = "2"
End Sub
Private Sub UserForm_Activate()
ComboBox1.AddItem "OCAK1"
ComboBox1.AddItem "OCAK2"
End Sub
Private Sub CommandButton1_Click()

If ComboBox2.Text = "1" Then
Sheets("Sayfa2").Select
Range("B3").Value = TextBox1.Value
Range("C3").Value = TextBox2.Value
Range("D3").Value = TextBox3.Value
Range("F3").Value = TextBox5.Value
Range("G3").Value = TextBox6.Value
Range("H3").Value = TextBox7.Value
Range("I3").Value = TextBox8.Value
End If
If ComboBox2.Text = "2" Then
Sheets("Sayfa2").Select
Range("B4").Value = TextBox1.Value
Range("C4").Value = TextBox2.Value
Range("D4").Value = TextBox3.Value
Range("F4").Value = TextBox5.Value
Range("G4").Value = TextBox6.Value
Range("H4").Value = TextBox7.Value
Range("I4").Value = TextBox8.Value
End If
End Sub
altarnatif
 
Geri
Üst