Sub updatedata()
Dim rw As Long, x As Range
Dim exportwb As Workbook, twb As Workbook
Set exportwb = Workbooks.Open("C:\Data.xls")
Set x = exportwb.Worksheets("Nhap diem").Range("B8:O1752")
Set toan = Sheet1
Set ly = Sheet2
Set hoa = Sheet3
Set sinh = Sheet4
Set van = Sheet6
Set su = Sheet7
Set dia = Sheet8
Set anh = Sheet9
Set gdcd = Sheet10
'Mon toan
With toan
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 12, False)
Next rw
End With
'Mon Ly
With ly
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 11, False)
Next rw
End With
'Mon Hoa
With hoa
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 6, False)
Next rw
End With
'Mon sinh
With sinh
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 13, False)
Next rw
End With
'Mon van
With van
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 9, False)
Next rw
End With
'Mon su
With su
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 6, False)
Next rw
End With
'Mon dia
With dia
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 8, False)
Next rw
End With
'Mon ANH
With anh
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 10, False)
Next rw
End With
'Mon gdcd
With gdcd
For rw = 8 To .Cells(Rows.Count, 2).End(xlUp).Row
.Cells(rw, 10) = Application.VLookup(.Cells(rw, 2).Value2, x, 14, False)
Next rw
End With
exportwb.Close savechanges:=False
End Sub