ต้องการบันทึกข้อมูลให้อยู่ในแถวเดิม
Posted: Fri Aug 17, 2018 7:29 pm
หาข้อมูลจากเลขที่ประเมินใน Sheet "db_Incomming Cars All"ด้วยปุ่ม"ค้นหา" เพื่อแก้ไขข้อมูลและบันทึกกลับแถวเดิมใน Sheet "db_Incomming Cars All"ด้วยปุ่ม "อัพเดทข้อมูล"
*ติดปัญหาคือ.อัพเดทข้อมูล.แล้วข้อมูลไปต่อแถวสุดท้ายไม่ทับแถวเดิมครับ
แนบ Code
*ติดปัญหาคือ.อัพเดทข้อมูล.แล้วข้อมูลไปต่อแถวสุดท้ายไม่ทับแถวเดิมครับ
แนบ Code
Code: Select all
Private Sub CommandButton3_Click()
Dim irow As Long
Dim ws As Worksheet
On Error Resume Next
If Err.Number = 13 Then
MsgBox "ไม่พบข้อมูล"
GoTo iNet
End If
If TextBox1.Text = "" Then
MsgBox "กรุณากรอกข้อมูล"
GoTo iNet
End If
Set ws = Worksheets("db_Incomming Cars All")
irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
If Application.CountIf(ws.Range("b:b"), TextBox1.Value) > 0 Then
irow = Application.Match(TextBox1.Value, ws.Range("b:b"), 0)
Else
irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
End If
ws.Cells(irow, 2) = TextBox1.Value
ws.Cells(irow, 3) = TextBox2.Value
ws.Cells(irow, 4) = TextBox3.Value
ws.Cells(irow, 5) = TextBox4.Value
ws.Cells(irow, 6) = TextBox5.Value
ws.Cells(irow, 7) = TextBox6.Value
ws.Cells(irow, 8) = TextBox7.Value
ws.Cells(irow, 9) = TextBox8.Value
ws.Cells(irow, 10) = TextBox9.Value
ws.Cells(irow, 11) = TextBox10.Value
ws.Cells(irow, 12) = TextBox11.Value
ws.Cells(irow, 13) = TextBox12.Value
ws.Cells(irow, 14) = TextBox13.Value
ws.Cells(irow, 15) = TextBox14.Value
ws.Cells(irow, 16) = TextBox15.Value
ws.Cells(irow, 17) = TextBox16.Value
ws.Cells(irow, 18) = TextBox17.Value
ws.Cells(irow, 19) = TextBox18.Value
ws.Cells(irow, 20) = TextBox19.Value
ws.Cells(irow, 21) = TextBox20.Value
ws.Cells(irow, 22) = TextBox21.Value
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 = " "
TextBox16.Text = " "
TextBox15.Text = " "
TextBox16.Text = " "
TextBox17.Text = " "
TextBox18.Text = " "
TextBox19.Text = " "
TextBox20.Text = " "
TextBox21.Text = " "
MsgBox "อัพเดทข้อมูลแล้ว"
ActiveWorkbook.Save
iNet:
End Sub