บันทึกข้อมูล ในชีท1และชัท2 พร้อมๆกัน ใช้คำสั่งไหนคับ (มือใหม่)
Posted: Tue Apr 27, 2021 6:21 pm
ตอนนี้คือผมบันทึกข้อมูล อยู่หน้าชีท บัญชีลูกค้า แล้วต้องการ บันทึกต่อจากชีท ข้อมูล ด้วยคับ
ชีท บัญชีลูกค้า --->> ต้องลงวันต่อวัน พอวันถัดไปต้องลบออกเพื่อเริ่มวันใหม่
ชีท ข้อมูล --->> สำหรับเก็บข้อมูลใว้เดือนต่อเดือน
วิธีที่ทำตอนนี้คือ ใช้วิธีการ 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
ชีท บัญชีลูกค้า --->> ต้องลงวันต่อวัน พอวันถัดไปต้องลบออกเพื่อเริ่มวันใหม่
ชีท ข้อมูล --->> สำหรับเก็บข้อมูลใว้เดือนต่อเดือน
วิธีที่ทำตอนนี้คือ ใช้วิธีการ 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