Sao không chạy dòng lệnh màu đỏ
Mình có đoạn code tự record như sau. Bình thường vẫn chạy tốt nhưng không hiểu sao được một vài hôm thì lại bị hỏng. Nguyên nhân có lẽ là do đoạn code màu đỏ đã không được thực hiện. Các bác xem hộ tại sao nhé
Sub Mergging1()
'
' Mergging Macro
' Macro recorded 2/5/2009 by thuy.dinh
'
' Keyboard Shortcut: Ctrl+Shift+K
'
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "=LEFT(R1C[-1],FIND(""X, 0, NO"",R1C[-1],1)+7)"
    Range("B2").Select
    ActiveCell.FormulaR1C1 = _
        "=LEFT(RIGHT(R1C[-1],LEN(R1C[-1])-SUM(OFFSET(R1C[1],,,ROW(R[-1]C[1]),1))),FIND(""X, 0, NO"",RIGHT(R1C[-1],LEN(R1C[-1])-SUM(OFFSET(R1C[1],,,ROW(R[-1]C[1]),1))),1)+7)"
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "=LEN(RC[-1])"
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "=LEN(RC[-1])"
    Range("B2:C2").Select
    Selection.AutoFill Destination:=Range("B2:C209"), Type:=xlFillDefault
    Range("B2:C209").Select
    ActiveWindow.SmallScroll Down:=-15
    Range("B6").Select
    Columns("B:B").EntireColumn.AutoFit
    Cells.Select
    Range("E10").Activate
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Columns("B:B").Select
    Selection.Replace What:=",", Replacement:="                       ", _
        LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
        False, ReplaceFormat:=False
        ActiveWindow.SmallScroll Down:=-9
    Columns("B:B").Select
    Selection.TextToColumns Destination:=Range("B1"), DataType:=xlFixedWidth, _
        FieldInfo:=Array(Array(0, 1), Array(28, 1), Array(53, 1), Array(80, 1), Array(112, 1), _
        Array(138, 1), Array(172, 1), Array(197, 1), Array(225, 1), Array(252, 1), Array(278, 1), _
        Array(325, 1), Array(350, 1), Array(376, 1)), TrailingMinusNumbers:=True
    Range("B12").Select
    Columns("B:B").EntireColumn.AutoFit
    Columns("B:B").ColumnWidth = 17.57
    Columns("E:E").ColumnWidth = 12
    Columns("D:E").Select
    Selection.Delete Shift:=xlToLeft
    Columns("E:H").Select
    Selection.Delete Shift:=xlToLeft
    Selection.ColumnWidth = 9.86
    Columns("F:I").Select
    Selection.Delete Shift:=xlToLeft
    Range("H4").Select
    Columns("E:E").ColumnWidth = 12.43
    Columns("A:A").ColumnWidth = 10
    Range("B1:E50").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection.Font
        .Name = "Tahoma"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Range("B1").Select
    Columns("B:B").Select
    Selection.Replace What:="#VALUE!", Replacement:="", _
        LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
        False, ReplaceFormat:=False
    Range("B1").Select
End Sub