以下VBA代码失败,错误1004,“范围类的自动填充方法失败。”。它在第一个工作表(i = 9)中效果很好,但是在下一个工作表中,它在Worksheets(i).Cells(Cel.Row, 6).Value = 0
之后失败了
Dim LastRow As Long
For i = 9 To 24 Step 1
LastRow = Worksheets(i).Cells(Worksheets(i).Rows.Count, "A").End(xlUp).Row
Worksheets(i).Range("C2:E" & LastRow).FillDown
Worksheets(i).Range("G2:G" & LastRow).FillDown
Set DniRange = Worksheets(i).Range("E2:E" & LastRow)
For Each Cel In DniRange.Cells
If Cel.Value = "0" Then
Worksheets(i).Cells(Cel.Row, 6).Value = 0
Worksheets(i).Cells(Cel.Row, 6).AutoFill Destination:=Range(Cells(Cel.Row, 6), Cells(LastRow, 6)), Type:=xlFillSeries
Worksheets(i).Cells(Cel.Row, 6).AutoFill Destination:=Range(Cells(Cel.Row, 6), Cells(2, 6)), Type:=xlFillSeries
End If
Next Cel
Next
有创意吗?