سلام.من ی user form با کد زیر ساختم،مشکل اینجاست که وقتی اولین اطلاعات رو وارد میکنی تا ستون دوم پر میکنه و باقی رو وارد نمیکنه،اما اگه به وارد کردن اطلاعات ادامه بدی مشکل رفع میشه(شاید نتونستم منظورمو برسونم عکس گذاشتم)
Private Sub CommandButton1_Click()
Dim rng As Range
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Or TextBox10.Text = "" Or TextBox11.Text = "" Or TextBox12.Text = "" Or TextBox13.Text = "" Or TextBox14.Text = "" Or TextBox15.Text = "" Or TextBox16.Text = "" Or TextBox17.Text = "" Or TextBox18.Text = "" Then
MsgBox " لطفااطلاعات را به صورت کامل وارد کنيد "
Exit Sub
End If
For Each rng In Range("C21:C65000")
If rng = "" Then
rng.Offset(0, 0) = TextBox1.Text
rng.Offset(0, 1) = TextBox2.Text
rng.Offset(0, 2) = TextBox3.Text
rng.Offset(0, 3) = TextBox4.Text
rng.Offset(0, 4) = TextBox5.Text
rng.Offset(0, 5) = TextBox6.Text
rng.Offset(0, 6) = TextBox7.Text
rng.Offset(0, 7) = TextBox8.Text
rng.Offset(0, 8) = TextBox9.Text
rng.Offset(0, 9) = TextBox10.Text
rng.Offset(0, 10) = TextBox11.Text
rng.Offset(0, 11) = TextBox12.Text
rng.Offset(0, 12) = TextBox13.Text
rng.Offset(0, 13) = TextBox14.Text
rng.Offset(0, 14) = TextBox15.Text
rng.Offset(0, 15) = TextBox16.Text
rng.Offset(0, 16) = TextBox17.Text
rng.Offset(0, 17) = TextBox18.Text
rng.Offset(0, 18) = TextBox19.Text
Exit For
End If
Next rng
TextBox1.Text = ""
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 = ""
TextBox16.Text = ""
TextBox17.Text = ""
TextBox18.Text = ""
TextBox19.Text = ""
End Sub
Private Sub CommandButton1_Click()
Dim rng As Range
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Or TextBox10.Text = "" Or TextBox11.Text = "" Or TextBox12.Text = "" Or TextBox13.Text = "" Or TextBox14.Text = "" Or TextBox15.Text = "" Or TextBox16.Text = "" Or TextBox17.Text = "" Or TextBox18.Text = "" Then
MsgBox " لطفااطلاعات را به صورت کامل وارد کنيد "
Exit Sub
End If
For Each rng In Range("C21:C65000")
If rng = "" Then
rng.Offset(0, 0) = TextBox1.Text
rng.Offset(0, 1) = TextBox2.Text
rng.Offset(0, 2) = TextBox3.Text
rng.Offset(0, 3) = TextBox4.Text
rng.Offset(0, 4) = TextBox5.Text
rng.Offset(0, 5) = TextBox6.Text
rng.Offset(0, 6) = TextBox7.Text
rng.Offset(0, 7) = TextBox8.Text
rng.Offset(0, 8) = TextBox9.Text
rng.Offset(0, 9) = TextBox10.Text
rng.Offset(0, 10) = TextBox11.Text
rng.Offset(0, 11) = TextBox12.Text
rng.Offset(0, 12) = TextBox13.Text
rng.Offset(0, 13) = TextBox14.Text
rng.Offset(0, 14) = TextBox15.Text
rng.Offset(0, 15) = TextBox16.Text
rng.Offset(0, 16) = TextBox17.Text
rng.Offset(0, 17) = TextBox18.Text
rng.Offset(0, 18) = TextBox19.Text
Exit For
End If
Next rng
TextBox1.Text = ""
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 = ""
TextBox16.Text = ""
TextBox17.Text = ""
TextBox18.Text = ""
TextBox19.Text = ""
End Sub
کامنت