
ลองตามนี้ครับ
ที่ชีท Payment เซลล์ I8 คีย์สูตรเพื่อเป็นยอดรวม
=SUM(OFFSET(I$4,0,0,ROW()-ROW(I$4)))
Enter > Copy ไปทางขวา
และเพิ่ม Code ที่ insertvatsale เป็นด้านล่าง
Code: Select all
Private Sub insertvatsale()
Dim rs As Range, rt As Range
On Error GoTo ll_error
With Worksheets("ºÑ¹·Ö¡ÃÒ¡ÒÃ")
Set rs = .Range("C3,C4,C5,C8,C10,C11,C12,C13,C14,C15,C16,C17")
End With
Set rt = Worksheets("payment").Range("A" & Rows.Count - 3) _
.End(xlUp).Offset(1, 0)
rs.Copy
rt.PasteSpecial Paste:=xlPasteValues, Transpose:=True
rt.Offset(1, 0).EntireRow.Insert 'Add this line
Application.CutCopyMode = False
'************end process********************
ll_exit:
On Error Resume Next
On Error GoTo 0
Exit Sub
ll_error:
MsgBox "Error Number " & Err.Number & " InsertVatSale" & vbCrLf & _
"Description " & Err.Description
Resume ll_exit
End Sub