Skip to content

Instantly share code, notes, and snippets.

@DuongAQ
Created January 22, 2018 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DuongAQ/c38c3f8f8fc4f0afa03077cbf6bf3c40 to your computer and use it in GitHub Desktop.
Save DuongAQ/c38c3f8f8fc4f0afa03077cbf6bf3c40 to your computer and use it in GitHub Desktop.
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"
Range("H6:K26").ClearContents
Exit Sub
Else
Application.ScreenUpdating = False
'Xóa dữ liệu cũ trong báo cáo
Range("H6:K26").ClearContents
'Mở chức năng lọc dữ liệu
Range("A2:F2").AutoFilter
'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(xlCellTypeVisible).Copy
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
ActiveSheet.Range("$A$2:$F$47").AutoFilter
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