|
下面的for next语句只执行了一步(y=10)就不执行了,求解。
Sub test()
Dim arr() As String, MaxRow As Integer
Dim X As Integer, y As Integer
X = 1
Sheets("消耗明细表原版").Select
For y = 10 To 21
If Len(Range("I" & y).Value) > 0 Then
Sheets("Sheet1").Range("A1") = Sheets("消耗明细表原版").Range("I" & y)
Sheets("Sheet1").Select
Columns("B:B").Select
Selection.NumberFormatLocal = "@"
arr = Split([A1], "、")
Range("B1").Resize(UBound(arr) + 1, 1) = Application.Transpose(arr)
Range("A:A").Delete
MaxRow = Worksheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row + 1
Do While X < MaxRow
Cells(X, 2) = Abs(Right(Cells(X, 1), 2) - Left(Cells(X, 1), 2)) + 1
X = X + 1
Loop
Range("C1") = Application.Sum(Range("b1:b" & MaxRow))
Sheets("消耗明细表原版").Range("F" & y) = Sheets("Sheet1").Range("C1")
Sheets("Sheet1").Range("A:C").ClearContents
End If
Next y
End Sub
|
|