Skip to content

Instantly share code, notes, and snippets.

Created January 22, 2018 08:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Sub Loc_BCCT()
'Biện luận trường hợp không phát sinh
If Range("N1").Value = 0 Then
MsgBox "Khong co du lieu phat sinh"
Exit Sub
Application.ScreenUpdating = False
'Xóa dữ liệu cũ trong báo cáo
'Mở chức năng lọc dữ liệu
'Lọc nội dung theo điều kiện
ActiveSheet.Range("$A$2:$F$47").AutoFilter Field:=2, Criteria1:=Range("I4").Value
ActiveSheet.Range("$A$2:$F$47").AutoFilter Field:=1, Criteria1:= _
">=" & CLng(Range("I2").Value), Operator:=xlAnd, Criteria2:="<=" & CLng(Range("I3").Value)
'Chọn nội dung cần Copy >> Sử dụng SpecialCells
Range("C3:F47").SpecialCells(12).Copy 'xlCellTypeVisible = 12
'Copy và Paste dữ liệu vào vị trí báo cáo
Range("H6").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Bỏ chức năng lọc
Application.ScreenUpdating = True
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment