nghiendhdt
Thành viên mới
- Tham gia
- 7/3/14
- Bài viết
- 7
- Được thích
- 0
Mọi người ơi, e mới học viết code mà bị cái lỗi này, nhờ a/c giúp dùm e với. (e có kèm theo file excel ạ)
Sub Macro1()
Dim i As Integer
For i = 6 To 8
Sheets("Sheet2").Select
Range("E2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-4]-Sheet1!RiC17>=0,Sheet2!RC[-3]-Sheet1!RiC18<=0),1,0)"
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E45")
Range("E2:E45").Select
Range("F1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[1]C:R[1048575]C)"
Range("F2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=1,Sheet1!RiC16*Sheet2!RC[-3]*Sheet2!RC[-2],0)"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F45")
Range("F2:F45").Select
Range("F1").Select
Selection.Copy
Sheets("Sheet1").Select
Range("S" & i).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Columns("E:F").Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("Sheet1").Select
Next i
End Sub
Sub Macro1()
Dim i As Integer
For i = 6 To 8
Sheets("Sheet2").Select
Range("E2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-4]-Sheet1!RiC17>=0,Sheet2!RC[-3]-Sheet1!RiC18<=0),1,0)"
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E45")
Range("E2:E45").Select
Range("F1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[1]C:R[1048575]C)"
Range("F2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=1,Sheet1!RiC16*Sheet2!RC[-3]*Sheet2!RC[-2],0)"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F45")
Range("F2:F45").Select
Range("F1").Select
Selection.Copy
Sheets("Sheet1").Select
Range("S" & i).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Columns("E:F").Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("Sheet1").Select
Next i
End Sub