Sub dung()
Dim i As String
Dim tennh(5) As String
tennh(0) = "ACBNA"
tennh(1) = "DDNA"
tennh(2) = "MSBNA"
tennh(3) = "KTNA"
tennh(4) = "VPBNA"
For i = tennh(0) To tennh(4)
Application.Workbooks.Open "C:\Tong hop toan dia ban\i.xls"
ActiveSheet.Unprotect
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Windows("Tong hop du lieu gstx toan dia ban.xls").Activate
Sheets("Tong hop toan dia ban").Select
Range("A1").Select
Selection.Copy
Windows("i.xls").Activate
Columns("A:J").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlAdd, SkipBlanks:= _
False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "i"
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Microsoft Sans Serif"
.FontStyle = "Regular"
.Size = 8.25
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("A2").Select
ActiveWorkbook.Save
ActiveWindow.Close
Name "C:\Tong hop toan dia ban\i.xls" As "C:\Tong hop toan dia ban\data.xls"
'mo 2 file data va tao cd ktoan'
Application.Workbooks.Open "C:\Tong hop toan dia ban\data.xls"
Application.Workbooks.Open "C:\Tong hop toan dia ban\Tao cd ktoan ver1.0.xls"
'copy so lieu tu file tao can doi ktoan vao'
Windows("Tao cd ktoan ver1.0.xls").Activate
Sheets("GSTX").Select
Range("A1
94").Select
Selection.Copy
Windows("Tong hop du lieu gstx toan dia ban.xls").Activate
Sheets("i").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("D2").Select
Columns("B:B").ColumnWidth = 17.29
Columns("C:C").ColumnWidth = 13.86
Columns("C:C").ColumnWidth = 17.71
Columns("B:B").ColumnWidth = 24.29
Columns("B:B").ColumnWidth = 35.86
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = ""
Columns("B:B").Select
Selection.ColumnWidth = 39.71
Range("B6").Select
Windows("Tao cd ktoan ver1.0.xls").Activate
Windows("Tong hop du lieu gstx toan dia ban.xls").Activate
Range("C15").Select
Windows("data.xls").Activate
ActiveWindow.Close
Kill "C:\Tong hop toan dia ban\data.xls"
Next
End Sub
khi chạy nó báo lỗi Type mismatch nhờ bác giúp đỡ với ạ