Option Explicit
Sub Bao_Cao()
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim ws_Data, ws_Report As Worksheet
Dim Source, SQL_Command As String
Source = ThisWorkbook.FullName
Set ws_Data = ThisWorkbook.Worksheets(SHEET_Data)
Set ws_Report = ThisWorkbook.Worksheets(SHEET_Report)
SQL_Command = "SELECT [Ma_san_pham],SUM(Mau_OK) AS OK, SUM(Mau_NG) AS NG FROM [Data$] WHERE [Nha_cung_cap] = " & "'" & ws_Report.Range("B1").Value & "'" & " AND" & " [Ngay_giao] = " & "#" & Format(ws_Report.Range("B2").Value, "yyyy/mm/dd") & "#" & " GROUP BY [Ma_san_pham]"
SQL_QUERY Source, SQL_Command, SHEET_Report, "F1"
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Bạn định dạng ngày kiểu gì mà sửa không được ah