Sub changecolor()
'
' changecolor 宏
' 根据计算得出的beta值正负,来改变对应单元格的字体颜色
'获取第一行的最大列数
Dim r As Integer
Dim c As Long
For r = 2 To 8
For c = 1 To 85
If Cells(r, c).Value < 0 Then
Cells(r, c).Font.ColorIndex = 5 And Cells(r + 22, [c]).Font.ColorIndex = 5
ElseIf Cells(r, c).Value > 0 Then
Cells(r, c).Font.ColorIndex = 3 & Cells([r + 22], [c]).Font.ColorIndex = 3
Else
Cells(r, c).Font.ColorIndex = 1 And Cells(r + 22, c).Font.ColorIndex = 1
End If
Next
Next
End Sub
1)当把cells(r+22,c)等内容去掉之后,模型可以正常运行;
但是当增加22行之后的单元格也按此执行之后,模型便报错;
求助是什么原因
不知道你这个问题是否已经解决, 如果还没有解决的话: