以下是我的VBA代码,提示说语法错误,请高手指导,我是菜鸟。
SubShowSum()Range("A1").Value=CalSum(200)EndSubFunctionCalSum(nAsInteger)AsInteger//提...
Sub ShowSum()
Range("A1").Value = CalSum(200)
End Sub
Function CalSum(n As Integer) As Integer//提示说这一行错误
Dim sum As Integer
sum = 0
For i = 1 To n Step 1
If i Mod 7 = 0
Then sum = sum + i
End If
Next CalSum = sum
End Function 展开
Range("A1").Value = CalSum(200)
End Sub
Function CalSum(n As Integer) As Integer//提示说这一行错误
Dim sum As Integer
sum = 0
For i = 1 To n Step 1
If i Mod 7 = 0
Then sum = sum + i
End If
Next CalSum = sum
End Function 展开
展开全部
请把换行输入正确
运行后正常,无问题,请试下先
Sub ShowSum()
Range("A1").Value = CalSum(200)
End Sub
Function CalSum(n As Integer) As Integer
Dim sum As Integer
sum = 0
For i = 1 To n Step 1
If i Mod 7 = 0 Then
sum = sum + i
End If
Next
CalSum = sum
End Function
运行后正常,无问题,请试下先
Sub ShowSum()
Range("A1").Value = CalSum(200)
End Sub
Function CalSum(n As Integer) As Integer
Dim sum As Integer
sum = 0
For i = 1 To n Step 1
If i Mod 7 = 0 Then
sum = sum + i
End If
Next
CalSum = sum
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询