บันทึกข้อมูลลง sheet
Posted: Wed Mar 06, 2013 1:32 pm
รบกวนผู้รู้ VBA ช่วยผมหน่อยครับ ติดปัญหาตรงที่ค้นหาข้อมูลจาก Userform เพื่อนำข้อมูลมาแก้ไข แล้วจะบันทึกทับในตำแหน่งเซลเดิม ไม่ทราบว่าต้องเขียน Code VBA ครับ.
คลังคำตอบแห่งความรู้จากคนไทย เพื่อโลกที่ต้องการเข้าใจในสิ่งเล็ก ๆ อย่างลึกซึ้ง
https://snasui.com/
Code: Select all
With Worksheets(db_sheet)
.Cells(blank_row, id_col).Value = form1.id_txtbox.Value
.Cells(blank_row, name_col).Value = form1.name_txtbox.Value
.Cells(blank_row, surname_col).Value = form1.surname_txtbox.Value
.Cells(blank_row, sex_col).Value = form1.sex_cbbox.Value
.Cells(blank_row, section_col).Value = form1.Section_txtbox.Value
.Cells(blank_row, Dept_col).Value = form1.Dept_cbbox.Value
End With
Code: Select all
Worksheets(db_sheet).Cells(data_row, name_col).Value = name_txtbox.Value
Worksheets(db_sheet).Cells(data_row, surname_col).Value = surname_txtbox.Value
Worksheets(db_sheet).Cells(data_row, sex_col).Value = sex_cbbox.Value
Worksheets(db_sheet).Cells(data_row, id_col).Value = id_txtbox.Value
Worksheets(db_sheet).Cells(data_row, section_col).Value = Section_txtbox.Value
Worksheets(db_sheet).Cells(data_row, Dept_col).Value = Dept_cbbox.Value
Code: Select all
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
Do Until id_check = id_txtbox.Text Or data_row > lastrow