Excel中运行时错误6 溢出,怎么解决啊,在线等~~~~急
计算双倍余额递减法的时候出现错误,VBA如下:Sub双倍余额递减法()DimyzAsIntegerDimnxAsIntegerDimczAsIntegerDimzjAsI...
计算双倍余额递减法的时候出现错误,VBA如下:
Sub 双倍余额递减法()
Dim yz As Integer
Dim nx As Integer
Dim cz As Integer
Dim zj As Integer
Dim zjh As Integer
Sheets("固定资产折旧处理系统").Select
yz = Cells(3, 2)
nx = Cells(4, 2)
cz = Cells(5, 2)
For i = 1 To nx
If nx - i = 1 Then
Cells(5 + i, 8) = (yz - cz) / 2
Cells(5 + i + 1, 8) = (yz - cz) / 2
Exit For
End If
Cells(5 + i, 8) = yz * 2 / nx
yz = yz - Cells(5 + i, 8)
Next i
Sheets("固定资产折旧处理系统").Select
End Sub
怎么解决???? 展开
Sub 双倍余额递减法()
Dim yz As Integer
Dim nx As Integer
Dim cz As Integer
Dim zj As Integer
Dim zjh As Integer
Sheets("固定资产折旧处理系统").Select
yz = Cells(3, 2)
nx = Cells(4, 2)
cz = Cells(5, 2)
For i = 1 To nx
If nx - i = 1 Then
Cells(5 + i, 8) = (yz - cz) / 2
Cells(5 + i + 1, 8) = (yz - cz) / 2
Exit For
End If
Cells(5 + i, 8) = yz * 2 / nx
yz = yz - Cells(5 + i, 8)
Next i
Sheets("固定资产折旧处理系统").Select
End Sub
怎么解决???? 展开
1个回答
展开全部
改成这样:
Sub 双倍余额递减法()
Dim yz,nx,cz,zj ,zjh
Sheets("固定资产折旧处理系统").Select
yz = Cells(3, 2)
nx = Cells(4, 2)
cz = Cells(5, 2)
For i = 1 To nx
if i<nx-1 then
Cells(5 + i, 8) = yz * 2 / nx
yz = yz - Cells(5 + i, 8)
else
Cells(5 + i, 8) = (yz - cz) / 2
End If
Next i
Sheets("固定资产折旧处理系统").Select
End Sub
测试一下,看看对不,不对继续问我,应该是没问题
Sub 双倍余额递减法()
Dim yz,nx,cz,zj ,zjh
Sheets("固定资产折旧处理系统").Select
yz = Cells(3, 2)
nx = Cells(4, 2)
cz = Cells(5, 2)
For i = 1 To nx
if i<nx-1 then
Cells(5 + i, 8) = yz * 2 / nx
yz = yz - Cells(5 + i, 8)
else
Cells(5 + i, 8) = (yz - cz) / 2
End If
Next i
Sheets("固定资产折旧处理系统").Select
End Sub
测试一下,看看对不,不对继续问我,应该是没问题
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询