for K=1 TO 3
if k=1 then M=3 AND N=22
if K=2 THEN M=25 AND n=26
IF K=3 THEN M=30 AND N=36
For i = m To n
If Cells(i, 7) < Range("G59") Then
Range(Cells(i - 1, 1), Cells(i - 1, 13)).Borders(xlEdgeBottom).Color = -16776961 '绘制红色平均线
Range(Cells(i - 1, 11), Cells(i - 1, 11)).FormulaR1C1 = "分部大盘基本任务达成率" & f
Range(Cells(i - 1, 10), Cells(i - 1, 13)).MergeCells = True
Range(Cells(i - 1, 1), Cells(i - 1, 13)).Borders(xlEdgeBottom).Weight = xlMedium '底边框为中等宽度的线
Exit For
End If
Next i
NEXT K
结果程序出错,M和n不是想要的数值,总是0,非要把实际的M,N带入循环,把循环代码依次写3回才行,求指点!