Kod kısaltma

Katılım
27 Aralık 2006
Mesajlar
59
Excel Vers. ve Dili
2003 Türkçe
Merhabalar,

Aşağıda bulunan kodu nasıl kısalta biliriz. Normalde 140 tane Texbox eklemem gerekiyor.

Private Sub OptionButton1_Change()
If OptionButton1 = True Then
Sheets("Sayfa2").Range("D3").Value = TextBox1.Text
TextBox2.Text = Sheets("Sayfa1").Range("A19").Value
TextBox3.Text = Sheets("Sayfa1").Range("A21").Value
TextBox4.Text = Sheets("Sayfa1").Range("A23").Value
TextBox5.Text = Sheets("Sayfa1").Range("A25").Value
TextBox6.Text = Sheets("Sayfa1").Range("A27").Value
TextBox7.Text = Sheets("Sayfa1").Range("A29").Value
TextBox8.Text = Sheets("Sayfa1").Range("A31").Value
TextBox9.Text = Sheets("Sayfa1").Range("A33").Value
TextBox10.Text = Sheets("Sayfa1").Range("A35").Value
TextBox11.Text = Sheets("Sayfa1").Range("A37").Value
TextBox12.Text = Sheets("Sayfa1").Range("A39").Value
TextBox13.Text = Sheets("Sayfa1").Range("A41").Value
TextBox14.Text = Sheets("Sayfa1").Range("A43").Value
TextBox15.Text = Sheets("Sayfa1").Range("A45").Value

Else
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
TextBox12.Text = ""
TextBox13.Text = ""
TextBox14.Text = ""
TextBox15.Text = ""
End If
End Sub
 

fedeal

Banned
Katılım
29 Mayıs 2008
Mesajlar
1,985
Excel Vers. ve Dili
2003 tr
Private Sub OptionButton1_Change()
If OptionButton1 = True Then
Sheets("Sayfa2").Range("D3").Value = TextBox1.Text
For i= 1 to 140
a= (i+8)*2
controls("textbox"&i+1).text=Sheets("Sayfa1").cells(a+1,1).value
next
else
For i= 1 to 140
controls("textbox"&i+1).text=""
next
End If
End Sub
denemedim umarım doğrudur 140 adet textbox için, iyi çalışmalar.
 
Son düzenleme:
Üst