VIP
VIP
'Thong tin ung ho dien dan:
'So tai khoan: 0011003264055
'Ngan hang Vietcombank
'Chi nhanh ngan hang: Quan Hoan Kiem, Ha Noi
'Chu tai khoan: Pham Minh Hoang
Sub main()
Dim sls As Integer 'So luong sheets
Dim i As Integer
Dim rend As Long, rend2 As Long, rghi As Long
Dim arr
Dim fghi As Boolean
Const r1 As Long = 5 'dong tieu de-du lieu bat dau tu dong 7
Const c3 As Integer = 3 'cot C-chua ten hang hoa
Const cend As Integer = 15
Const shn As String = "DT T6" 'Ten sheet tong hop
shs = ThisWorkbook.Sheets.Count
'Xoa du lieu
On Error GoTo thoat
With ThisWorkbook.Sheets(shn)
rend = .Cells(.Rows.Count, c3).End(xlUp).Row
If rend >= (r1 + 2) Then
.Range(.Cells(r1 + 2, c3 - 2), .Cells(rend, cend)).ClearContents
End If
End With
rghi = 6
For i = 1 To shs Step 1
If ThisWorkbook.Sheets(i).Name <> shn Then
fghi = False
'Lay du lieu
With ThisWorkbook.Sheets(i)
rend = .Cells(.Rows.Count, c3).End(xlUp).Row
If rend >= (r1 + 2) Then
arr = .Range(.Cells(r1 + 2, c3 - 1), .Cells(rend, cend)).Value
fghi = True
End If
End With
'Ghi ket qua
If fghi = True Then
rghi = rghi + 1
rend2 = UBound(arr, 1) - LBound(arr, 1) + rghi
With ThisWorkbook.Sheets(shn)
.Range(.Cells(rghi, c3 - 1), .Cells(rend2, cend)).Value = arr
End With
rghi = rend2
End If
End If
Next i
'Ghi so thu tu vao sheet ket qua:
If rghi >= 7 Then
With ThisWorkbook.Sheets(shn)
For i = 1 To rghi Step 1
.Cells(i+6,c3 - 2).Value = i
Next i
End With
End If
MsgBox "Da hoan thanh"
Exit Sub
thoat:
End Sub