ต้องการให้ Userform บันทึกข้อมูลไปหน้าช้อมูลสมาชิก
Posted: Wed Jul 10, 2019 1:16 pm
Form นี้ผมสร้างโค้ดเพื่อให้บันทึกคือ Sheet1 ที่ตีตารางแล้วให้บันทึกในExcel ใน sheet1
ที่นี้ Sheetชื่อ Home จะเป็นปุ่มกดต่างๆ ซึ่งมีปุ่มนึงคือ ปุ่มกดสมัครสมาชิก
ตอนนี้กำลังหัดทำอยู่ครับคือการ คีย์ข้อมูลสมาชิก
แต่ให้ Form ปุ่มนี้เวลากรอกข้อมูลให้เซฟลงตาราง Excel ใน Sheet1 ไม่ใช่เซฟข้อมูลที่กรอกใน Sheetชื่อ Home
ต้องใส่สูตรอย่างไรครับ
Private Sub CommandButton1_Click()
Do
r = r + 1
Loop Until Cells(r, 1) = ""
Cells(r, 1) = Box1.Text
Cells(r, 2) = Box2.Text
Cells(r, 4) = Box3.Text
Cells(r, 5) = Box4.Text
Cells(r, 6) = Box5.Text
Cells(r, 7) = Box6.Text
Cells(r, 8) = Box7.Text
Cells(r, 9) = Box8.Text
Cells(r, 11) = Box9.Text
Cells(r, 12) = Box10.Text
Cells(r, 13) = Box11.Text
Cells(r, 14) = Box12.Text
Cells(r, 15) = Box13.Text
Cells(r, 16) = Box14.Text
Cells(r, 17) = Box15.Text
Cells(r, 18) = Box16.Text
Cells(r, 19) = Box17.Text
Cells(r, 20) = Box18.Text
Cells(r, 21) = Box19.Text
Cells(r, 22) = Box20.Text
Cells(r, 23) = Box21.Text
Cells(r, 24) = Box22.Text
Cells(r, 25) = Box23.Text
Cells(r, 26) = Box24.Text
Cells(r, 27) = Box25.Text
If OptionButton1.Value = True Then
Cells(r, 3) = "Boy"
Else
Cells(r, 3) = "Girl"
End If
End Sub
ที่นี้ Sheetชื่อ Home จะเป็นปุ่มกดต่างๆ ซึ่งมีปุ่มนึงคือ ปุ่มกดสมัครสมาชิก
ตอนนี้กำลังหัดทำอยู่ครับคือการ คีย์ข้อมูลสมาชิก
แต่ให้ Form ปุ่มนี้เวลากรอกข้อมูลให้เซฟลงตาราง Excel ใน Sheet1 ไม่ใช่เซฟข้อมูลที่กรอกใน Sheetชื่อ Home
ต้องใส่สูตรอย่างไรครับ
Private Sub CommandButton1_Click()
Do
r = r + 1
Loop Until Cells(r, 1) = ""
Cells(r, 1) = Box1.Text
Cells(r, 2) = Box2.Text
Cells(r, 4) = Box3.Text
Cells(r, 5) = Box4.Text
Cells(r, 6) = Box5.Text
Cells(r, 7) = Box6.Text
Cells(r, 8) = Box7.Text
Cells(r, 9) = Box8.Text
Cells(r, 11) = Box9.Text
Cells(r, 12) = Box10.Text
Cells(r, 13) = Box11.Text
Cells(r, 14) = Box12.Text
Cells(r, 15) = Box13.Text
Cells(r, 16) = Box14.Text
Cells(r, 17) = Box15.Text
Cells(r, 18) = Box16.Text
Cells(r, 19) = Box17.Text
Cells(r, 20) = Box18.Text
Cells(r, 21) = Box19.Text
Cells(r, 22) = Box20.Text
Cells(r, 23) = Box21.Text
Cells(r, 24) = Box22.Text
Cells(r, 25) = Box23.Text
Cells(r, 26) = Box24.Text
Cells(r, 27) = Box25.Text
If OptionButton1.Value = True Then
Cells(r, 3) = "Boy"
Else
Cells(r, 3) = "Girl"
End If
End Sub