Sub cho nut ban hang
Mã:
Sub ban_hang()
Dim cur_row As Long
Dim table_lrow As Long
With Sheet2
cur_row = .Cells(.Rows.Count, 5).End(xlUp).Row + 1
.Range("A3", "A" & cur_row) = Format(Date, "mm-dd-yyyy")
End With
With Sheet1
.Range("c6").Copy
Sheet2.Range("a" & cur_row).PasteSpecial xlPasteValues
.Range("e6").Copy Destination:=Sheet2.Range("b" & cur_row)
.Range("D7").Copy Destination:=Sheet2.Range("c" & cur_row)
.Range("F7").Copy Destination:=Sheet2.Range("d" & cur_row)
table_lrow = .Range("d8").End(xlDown).Row
.Range("c9", "c" & table_lrow).Copy Destination:=Sheet2.Range("e" & cur_row)
.Range("d9", "d" & table_lrow).Copy Destination:=Sheet2.Range("f" & cur_row)
.Range("e9", "e" & table_lrow).Copy Destination:=Sheet2.Range("g" & cur_row)
End With
End Sub
Code cho nut moi
Mã:
Sub moi()
Dim table_lrow As Long
With Sheet1
.Range("c6") = Now()
.Range("e6").Value = .Range("e6").Value + 1
.Range("d7", "f7").ClearContents
table_lrow = .Range("d8").End(xlDown).Row
.Range("b9", "e" & table_lrow).ClearContents
End With
End Sub