Page 1 of 1

บันทึกข้อมูล ในชีท1และชัท2 พร้อมๆกัน ใช้คำสั่งไหนคับ (มือใหม่)

Posted: Tue Apr 27, 2021 6:21 pm
by saiful1882
ตอนนี้คือผมบันทึกข้อมูล อยู่หน้าชีท บัญชีลูกค้า แล้วต้องการ บันทึกต่อจากชีท ข้อมูล ด้วยคับ

ชีท บัญชีลูกค้า --->> ต้องลงวันต่อวัน พอวันถัดไปต้องลบออกเพื่อเริ่มวันใหม่
ชีท ข้อมูล --->> สำหรับเก็บข้อมูลใว้เดือนต่อเดือน

วิธีที่ทำตอนนี้คือ ใช้วิธีการ copy แบบคลิ๊กเมาส์ อยากให้มันบันทึกข้อมูลได้เลยคับ

Private Sub CommandButton1_Click()

Dim answer As Integer
answer = MsgBox("Are you sure you want to empty the sheet?", vbYesNo + vbQuestion, "Empty Sheet")

If answer = vbYes Then

emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1


Cells(emptyRow, 1).Value = TextBox1.Value
Cells(emptyRow, 3).Value = TextBox2.Value
Cells(emptyRow, 4).Value = TextBox3.Value
Cells(emptyRow, 5).Value = TextBox4.Value
Cells(emptyRow, 7).Value = TextBox5.Value
Cells(emptyRow, 8).Value = TextBox6.Value
Cells(emptyRow, 10).Value = TextBox7.Value
Cells(emptyRow, 11).Value = TextBox8.Value
Cells(emptyRow, 12).Value = TextBox9.Value

TextBox1.Value = ""
TextBox2.Value = ""
TextBox5.Value = ""
TextBox7.Value = 0
TextBox8.Value = 0
TextBox9.Value = 0

Else

End If

Sheets("บัญชีลูกค้า").Range("B:B").Copy Sheets("ข้อมูล").Range("A1 ")

TextBox1.SetFocus

End Sub

Re: บันทึกข้อมูล ในชีท1และชัท2 พร้อมๆกัน ใช้คำสั่งไหนคับ (มือใหม่)

Posted: Tue Apr 27, 2021 8:04 pm
by snasui
:D กรุณาแนบไฟล์ที่มี Code นี้มาแล้วด้วยจะได้สะดวกในการตอบของเพื่อนสมาชิก

อ่านกฎการใช้บอร์ดข้อ 4 และ 5 ด้านบนประกอบครับ :roll:

Re: บันทึกข้อมูล ในชีท1และชัท2 พร้อมๆกัน ใช้คำสั่งไหนคับ (มือใหม่)

Posted: Tue Apr 27, 2021 11:17 pm
by saiful1882
อัพไฟล์ไม่ได้คับ แจ้งว่าขนาดใหญ่เกินไปคับ

Code: Select all

Private Sub CommandButton1_Click()

Dim answer As Integer
answer = MsgBox("Are you sure you want to empty the sheet?", vbYesNo + vbQuestion, "Empty Sheet")

If answer = vbYes Then

emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1


Cells(emptyRow, 1).Value = TextBox1.Value
Cells(emptyRow, 3).Value = TextBox2.Value
Cells(emptyRow, 4).Value = TextBox3.Value
Cells(emptyRow, 5).Value = TextBox4.Value
Cells(emptyRow, 7).Value = TextBox5.Value
Cells(emptyRow, 8).Value = TextBox6.Value
Cells(emptyRow, 10).Value = TextBox7.Value
Cells(emptyRow, 11).Value = TextBox8.Value
Cells(emptyRow, 12).Value = TextBox9.Value

TextBox1.Value = ""
TextBox2.Value = ""
TextBox5.Value = ""
TextBox7.Value = 0
TextBox8.Value = 0
TextBox9.Value = 0

Else

End If

Sheets("บัญชีลูกค้า").Range("B:B").Copy Sheets("ข้อมูล").Range("A1 ")

TextBox1.SetFocus

End Sub

Re: บันทึกข้อมูล ในชีท1และชัท2 พร้อมๆกัน ใช้คำสั่งไหนคับ (มือใหม่)

Posted: Tue Apr 27, 2021 11:20 pm
by snasui
saiful1882 wrote: Tue Apr 27, 2021 11:17 pm อัพไฟล์ไม่ได้คับ แจ้งว่าขนาดใหญ่เกินไปคับ
:D คำว่า "คับ" ผิดกฎการใช้บอร์ดข้อ 1 ด้านบนครับ :roll:

ทำตัวอย่างไฟล์ขึ้นมาใหม่ ตัดมาถามมาเฉพาะที่เป็นปัญหา ไม่ควรแนบไฟล์จริงมาถามครับ