Page 1 of 1

ต้องการให้ Userform บันทึกข้อมูลไปหน้าช้อมูลสมาชิก

Posted: Wed Jul 10, 2019 1:16 pm
by novaholy
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

Re: ต้องการให้ Userform บันทึกข้อมูลไปหน้าช้อมูลสมาชิก

Posted: Wed Jul 10, 2019 1:43 pm
by puriwutpokin
ควรแนบไฟล์ตัวอย่างมาด้วยครับ และ วางโค้ดให้เป็นโค้ดดูวิธีจาก Forum rules ข้อ5 ของเว็บด้วยครับ

Re: ต้องการให้ Userform บันทึกข้อมูลไปหน้าช้อมูลสมาชิก

Posted: Thu Jul 11, 2019 12:41 am
by novaholy
puriwutpokin wrote: Wed Jul 10, 2019 1:43 pm ควรแนบไฟล์ตัวอย่างมาด้วยครับ และ วางโค้ดให้เป็นโค้ดดูวิธีจาก Forum rules ข้อ5 ของเว็บด้วยครับ
โทษทีครับ ไฟล์แนบนะครับ

Re: ต้องการให้ Userform บันทึกข้อมูลไปหน้าช้อมูลสมาชิก

Posted: Thu Jul 11, 2019 5:52 am
by snasui
:D ตัวอย่าง Code ครับ

Code: Select all

'Other code
With Worksheets("Sheet1")
    Do
        r = r + 1
    Loop Until Cells(r, 1) = ""
    .Cells(r, 1) = Box1.Text
    .Cells(r, 2) = Box2.Text
    .Cells(r, 4) = Box3.Text
    'Other code
End With
'Other code

Re: ต้องการให้ Userform บันทึกข้อมูลไปหน้าช้อมูลสมาชิก

Posted: Thu Jul 11, 2019 5:44 pm
by novaholy
ใส่ Codeแล้วครับ เวลากดปุ่ม Register sheet ชื่อ" Home"
ตรงปุ่ม สมัครสมาชิก มันไม่ไปบันทึก Sheet "Register"ครับ
ยังบันทึกหน้า Home อยู่ แก้ไขยังไงครับ

ขอบคุณครับ

Re: ต้องการให้ Userform บันทึกข้อมูลไปหน้าช้อมูลสมาชิก

Posted: Thu Jul 11, 2019 6:33 pm
by snasui
:D หน้า Cells มี จุด ด้วยครับ

จะต้องเป็น .Cells ไม่ใช่ Cells เฉย ๆ ครับ

Re: ต้องการให้ Userform บันทึกข้อมูลไปหน้าช้อมูลสมาชิก

Posted: Thu Jul 11, 2019 10:42 pm
by novaholy
snasui wrote: Thu Jul 11, 2019 6:33 pm :D หน้า Cells มี จุด ด้วยครับ

จะต้องเป็น .Cells ไม่ใช่ Cells เฉย ๆ ครับ
ได้แล้วครับขอบคุณครับ