Sub Tonghop()
Dim Sh As Worksheet, Rws As Long, MyColor As Byte
Dim Cls As Range, Rng As Range
Set Sh = Sheets("tong hop")
Rws = Range([c14], [c14].End(xlDown)).Rows.Count 'vi tri dong can copy tren sheet chi tuet
If Rws > 500 Then Rws = 1
MyColor = _
MsgBox("Ban Càn Chép Sang 'TongHop' " & Rws & " Dòng?", vbYesNo + vbQuestion, "GPE")
'If MyColor = 6 Then
' MyColor = [b3].Interior.ColorIndex +
Set Rng = Sh.[C65500].End(xlUp).Offset(1) 'Chon vi tri tren sheet tong hop de xu ly du lieu
With Rng
'.Offset(, -2).Resize(Rws).Value = [D8].Value ' chon ben trai cot D tren sheet tong hop cot thu 4 = gia tri E8 tren sheet chi tiet
.Offset(, -1).Resize(Rws).Value = [F6].Value ' chon ben trai cot D tren sheet tong hop cot thu 3 = gia tri F6 tren sheet chi tiet
'.Offset(, -1).Resize(Rws).Value = "=IF(RC[1]<>0,CONCATENATE(97041800,RC[1]),"""")" 'Gan cong thuc tai ben trai cot D tren sheet tong hop cot thu 2
'.Offset(, -1).Resize(Rws).Value = [F6].Value
'.Offset(, -1).Resize(Rws).Value = [c14].Value
'.Resize(Rws, 50).Value = Cells(14, "c").Resize(Rws, 20).Value
'.Offset(, -1).Resize(Rws).Value = [r6].Value
.Resize(Rws, 10).Value = Cells(14, "C").Resize(Rws, 15).Value
'copy 7 gia tri ke tu cot C 14 tren sh Du lieu sang cot D tren sheeet tong hop
3 '.Offset(, 15).Resize(Rws).Value = [c4].Value
.Resize(Rws, 20).Value = Cells(14, "C").Resize(Rws, 20).Value
End With
Sheets("Tong hop").Select
Range("C2:C65000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Chi tiet").Select
ActiveSheet.Range("$B$12:$I$526").AutoFilter Field:=1, Criteria1:="<>"
5 ' Null Amount If Inv Type<> "Z000"'
'For Each Cls In Rng.Offset(, 5).Resize(Rws)
' If Cls.Value <> "Z000" Then Cls.Offset(, 1).Value = ""
'Next Cls
'If MyColor > 42 Then MyColor = 34
'[b3].Interior.ColorIndex = MyColor
'[B7].Resize(Rws, 16).Value = ""
' End If
ActiveWorkbook.Save
End Sub
Dim Sh As Worksheet, Rws As Long, MyColor As Byte
Dim Cls As Range, Rng As Range
Set Sh = Sheets("tong hop")
Rws = Range([c14], [c14].End(xlDown)).Rows.Count 'vi tri dong can copy tren sheet chi tuet
If Rws > 500 Then Rws = 1
MyColor = _
MsgBox("Ban Càn Chép Sang 'TongHop' " & Rws & " Dòng?", vbYesNo + vbQuestion, "GPE")
'If MyColor = 6 Then
' MyColor = [b3].Interior.ColorIndex +
Set Rng = Sh.[C65500].End(xlUp).Offset(1) 'Chon vi tri tren sheet tong hop de xu ly du lieu
With Rng
'.Offset(, -2).Resize(Rws).Value = [D8].Value ' chon ben trai cot D tren sheet tong hop cot thu 4 = gia tri E8 tren sheet chi tiet
.Offset(, -1).Resize(Rws).Value = [F6].Value ' chon ben trai cot D tren sheet tong hop cot thu 3 = gia tri F6 tren sheet chi tiet
'.Offset(, -1).Resize(Rws).Value = "=IF(RC[1]<>0,CONCATENATE(97041800,RC[1]),"""")" 'Gan cong thuc tai ben trai cot D tren sheet tong hop cot thu 2
'.Offset(, -1).Resize(Rws).Value = [F6].Value
'.Offset(, -1).Resize(Rws).Value = [c14].Value
'.Resize(Rws, 50).Value = Cells(14, "c").Resize(Rws, 20).Value
'.Offset(, -1).Resize(Rws).Value = [r6].Value
.Resize(Rws, 10).Value = Cells(14, "C").Resize(Rws, 15).Value
'copy 7 gia tri ke tu cot C 14 tren sh Du lieu sang cot D tren sheeet tong hop
3 '.Offset(, 15).Resize(Rws).Value = [c4].Value
.Resize(Rws, 20).Value = Cells(14, "C").Resize(Rws, 20).Value
End With
Sheets("Tong hop").Select
Range("C2:C65000").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Chi tiet").Select
ActiveSheet.Range("$B$12:$I$526").AutoFilter Field:=1, Criteria1:="<>"
5 ' Null Amount If Inv Type<> "Z000"'
'For Each Cls In Rng.Offset(, 5).Resize(Rws)
' If Cls.Value <> "Z000" Then Cls.Offset(, 1).Value = ""
'Next Cls
'If MyColor > 42 Then MyColor = 34
'[b3].Interior.ColorIndex = MyColor
'[B7].Resize(Rws, 16).Value = ""
' End If
ActiveWorkbook.Save
End Sub