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
 

ynmcan

Altın Üye
Katılım
30 Ağustos 2008
Mesajlar
677
Excel Vers. ve Dili
2010 türkçe
Altın Üyelik Bitiş Tarihi
29-05-2025
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
 
Katılım
14 Aralık 2007
Mesajlar
1,073
Excel Vers. ve Dili
EXCEL 2007 TÜRKÇE
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
 
Üst