อาจารย์คะ ขอรบกวนเรื่องปรับโค๊ดเมือกดปุ่ม UpdateEmp ที่ชีท Update ต้องการให้บันทึกข้อมูลมาต่อท้ายข้อมูลที่ชีท TemplateIn โดยการบันทึกไม่ได้ต่อเนื่องกันมีเว้นช่วงเซลล์ด้วยค่ะแบ่งเป็น 3 ช่วง
ช่วงที่ 1 เซลล์ A2 ของชีท Update ไปต่อท้ายข้อมูลที่เซลล์ A2 ของชีท TemplateIn และ เว้นเซลล์ B2
ช่วงที่ 2 เซลล์ B2:E2 ของชีท Update ไปต่อท้ายข้อมูลที่เซลล์ C2:F2 ของชีท TemplateIn และ เว้นเซลล์ G2:L2
ช่วงที่ 3 เซลล์ F2:I2 ของชีท Update ไปต่อท้ายข้อมูลที่เซลล์ M2:P2ของชีท TemplateIn
Code: Select all
Sub UpdateEmp()
Dim rSource As Range
Dim rTarget As Range
Set rSource = Worksheets("Update").Range("A2")
Set rSource = Worksheets("Update").Range("B2:E2")
Set rSource = Worksheets("Update").Range("F2:I2")
Set rTarget = Worksheets("TemplateIn").Range("A" & Rows.Count).End(xlUp) _
.Offset(1, 0).Resize(lng + 1, 2)
Set rTarget = Worksheets("TemplateIn").Range("C:F").End(xlUp).Offset(1, 0)
Set rTarget = Worksheets("TemplateIn").Range("M:P").End(xlUp).Offset(1, 0)
rSource.Copy
rTarget.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("Update").Range("A2,D2,F2:G2").ClearContents
End Sub
ได้แนบไฟล์ตัวอย่าง Code อยู่ Module1 ชื่อ UpdateEmp โค๊ดนี้ลองแล้ว นำข้อมูลมาบันทึกได้แค่คอลัมน์ M:P เท่านั้นค่ะ แถม Error อีกด้วยค่ะ
ขอบคุณค่ะ
You do not have the required permissions to view the files attached to this post.